[LTP] [PATCH v2 2/2] setpgid03: Add test for PGID in different session
Teo Couprie Diaz
teo.coupriediaz@arm.com
Thu Apr 20 18:09:10 CEST 2023
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>
---
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 b23d662e9..9ce2603d8 100644
--- a/testcases/kernel/syscalls/setpgid/setpgid03.c
+++ b/testcases/kernel/syscalls/setpgid/setpgid03.c
@@ -11,6 +11,8 @@
*
* Tests setpgid(2) errors:
*
+ * - 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);
--
2.34.1
More information about the ltp
mailing list