public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clone.2: Fix the erroneous statement about CLONE_NEWPID
@ 2023-08-10  2:26 Sargun Dhillon
  2023-08-12 17:48 ` Alejandro Colomar
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Sargun Dhillon @ 2023-08-10  2:26 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-08-13 14:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-10  2:26 [PATCH] clone.2: Fix the erroneous statement about CLONE_NEWPID Sargun Dhillon
2023-08-12 17:48 ` Alejandro Colomar
2023-08-12 17:51   ` Alejandro Colomar
2023-08-12 19:05     ` John Watts
2023-08-13  0:57       ` Sargun Dhillon
2023-08-13 13:17         ` [PATCH v2] clone.2: Fix outdated " Alejandro Colomar
2023-08-13 13:35           ` Serge E. Hallyn
2023-08-13 13:40             ` Alejandro Colomar
2023-08-13 13:53               ` Serge E. Hallyn
2023-08-13 13:55 ` [PATCH v3] clone.2: Fix erroneous statement about CLONE_NEWPID|CLONE_PARENT Alejandro Colomar
2023-08-13 14:03   ` Alejandro Colomar
2023-08-13 14:36   ` Serge E. Hallyn
2023-08-13 14:37     ` Alejandro Colomar
2023-08-13 14:40       ` Alejandro Colomar
2023-08-13 14:14 ` [PATCH v4] " Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox