[PATCH] clone.2: Fix the erroneous statement about CLONE_NEWPID

Sargun Dhillon
2023-08-10T02:26:12Z

It appears like the documentation is based on out of date information in
regards to using CLONE_NEWPID and CLONE_PARENT together.

For example, in this test program, one can see that it works:

static pid_t sys_clone3(struct clone_args *args)
{
fflush(stdout);
fflush(stderr);
return syscall(__NR_clone3, args, sizeof(*args));
}

int main() {
struct clone_args args = {
.flags = CLONE_PARENT | CLONE_NEWPID,
};
int ret;

printf("The main program is running with pid: %d, and ppid: %d\n", getpid(), getppid());
ret = sys_clone3(&args);
assert(ret != -1);
if (ret == 0) {
printf("This is the child, running with pid: %d, and ppid: %d\n", getpid(), getppid());
_exit(0);
}

return 0;
}

This test program (successfully) outputs:
The main program is running with pid: 648411, and ppid: 648397
This is the child, running with pid: 1, and ppid: 0

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
---
man2/clone.2 | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/man2/clone.2 b/man2/clone.2
index 4c5b4ac6b..96ad24b95 100644
--- a/man2/clone.2
+++ b/man2/clone.2
@@ -736,9 +736,7 @@ Only a privileged process
can employ
.BR CLONE_NEWPID .
This flag can't be specified in conjunction with
-.B CLONE_THREAD
-or
-.BR CLONE_PARENT .
+.B CLONE_THREAD.
.TP
.B CLONE_NEWUSER
(This flag first became meaningful for
--
2.39.3