The current test in setpgid03 generates EPERM because the child is a session leader, as it has called setsid(). EPERM can also happen by trying to change to a PGID in another session. This was previously done in setpgid02, but it could fail on some systems.
setpgid03 provides a guaranteed way to generate this error by forking and setsid() in the child, so add a test for it here.
Update the description to reflect this understanding.
Signed-off-by: Teo Couprie Diaz teo.coupriediaz@arm.com Reviewed-by: Li Wang liwang@redhat.com Reviewed-by: Cyril Hrubis chrubis@suse.cz --- testcases/kernel/syscalls/setpgid/setpgid03.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/testcases/kernel/syscalls/setpgid/setpgid03.c b/testcases/kernel/syscalls/setpgid/setpgid03.c index 79ca23e08..b747dacaf 100644 --- a/testcases/kernel/syscalls/setpgid/setpgid03.c +++ b/testcases/kernel/syscalls/setpgid/setpgid03.c @@ -11,6 +11,8 @@ * * Tests setpgid() erorrs: * + * - EPERM The process specified by pid must not be a session leader. + * * - EPERM The calling process, process specified by pid and the target * process group must be in the same session. * @@ -43,6 +45,8 @@ static void run(void) TST_CHECKPOINT_WAIT(0);
TST_EXP_FAIL(setpgid(child_pid, getppid()), EPERM); + /* Child did setsid(), so its PGID is set to its PID. */ + TST_EXP_FAIL(setpgid(0, child_pid), EPERM);
TST_CHECKPOINT_WAKE(0);