Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2019-01-17 23:33:04 +0300
committerAndrei Vagin <avagin@gmail.com>2019-04-21 06:25:26 +0300
commit1be8269cd0633fddfd29cda40b59da4bd95b5b26 (patch)
tree782c4f02725df7f90524beea2454d318d3c6a071 /test
parent901f5d48ec6ef485ea889a4a97011a12f4c3808e (diff)
Avoid unnecessary getpid() calls
getsid(0) and getpgid(0) will return session ID and PGID of the calling process. Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com> Signed-off-by: Andrei Vagin <avagin@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/zdtm/static/session00.c4
-rw-r--r--test/zdtm/static/session01.c12
-rw-r--r--test/zdtm/static/session03.c2
3 files changed, 9 insertions, 9 deletions
diff --git a/test/zdtm/static/session00.c b/test/zdtm/static/session00.c
index 5889a92b9..4a239e159 100644
--- a/test/zdtm/static/session00.c
+++ b/test/zdtm/static/session00.c
@@ -90,7 +90,7 @@ static int fork_child(int i)
close(p[1]);
wait(NULL);
- if (getsid(getpid()) != sid) {
+ if (getsid(0) != sid) {
fail("The process %d (%x) has SID=%d (expected %d)",
pid, testcases[i].flags, sid, testcases[i].sid);
exit(1);
@@ -117,7 +117,7 @@ static int fork_child(int i)
close(p[1]);
wait(NULL);
- if (getsid(getpid()) != sid) {
+ if (getsid(0) != sid) {
fail("The process %d (%x) has SID=%d (expected %d)",
pid, testcases[i].flags, sid, testcases[i].sid);
exit(1);
diff --git a/test/zdtm/static/session01.c b/test/zdtm/static/session01.c
index 20c0d51cb..48cfb26de 100644
--- a/test/zdtm/static/session01.c
+++ b/test/zdtm/static/session01.c
@@ -102,14 +102,14 @@ static int child(const int c)
goto err;
if (t->pid == t->sid) {
- if (getpid() != getsid(getpid()))
+ if (getpid() != getsid(0))
if (setsid() < 0)
goto err;
if (fork_children(t, 1))
goto err;
}
if (t->pid == t->pgid) {
- if (getpid() != getpgid(getpid()))
+ if (getpid() != getpgid(0))
if (setpgid(getpid(), getpid()) < 0) {
pr_perror("setpgid() failed");
goto err;
@@ -129,7 +129,7 @@ static int child(const int c)
break;
if (t->pgid != testcases[i].pid)
continue;
- if (getpgid(getpid()) != testcases[i].master.pid)
+ if (getpgid(0) != testcases[i].master.pid)
if (setpgid(getpid(), testcases[i].master.pid) < 0) {
pr_perror("setpgid() failed (%d) (%d)", c, i);
goto err;
@@ -161,7 +161,7 @@ static int child(const int c)
/* Save the master copy */
t->master.ppid = getppid();
- t->master.sid = getsid(getpid());
+ t->master.sid = getsid(0);
futex_set_and_wake(&t->futex, c);
@@ -169,8 +169,8 @@ static int child(const int c)
check("pid", t->master.pid, getpid());
check("ppid", t->master.ppid, getppid());
- check("sid", t->master.sid, getsid(getpid()));
- check("pgid", t->master.pgid, getpgid(getpid()));
+ check("sid", t->master.sid, getsid(0));
+ check("pgid", t->master.pgid, getpgid(0));
futex_set_and_wake(&t->futex, c);
diff --git a/test/zdtm/static/session03.c b/test/zdtm/static/session03.c
index 04fb83461..2b3c46c32 100644
--- a/test/zdtm/static/session03.c
+++ b/test/zdtm/static/session03.c
@@ -177,7 +177,7 @@ static void handle_command()
}
break;
case TEST_SETSID:
- if (getsid(getpid()) == getpid())
+ if (getsid(0) == getpid())
break;
test_msg("%3d: setsid()\n", current);
if(setsid() == -1) {