diff options
| author | Michael Kerrisk <mtk.manpages@gmail.com> | 2019-09-25 15:59:12 +0200 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2019-10-10 12:24:28 +0200 |
| commit | 13ad736507d1def4e2f24000b24bf5d7ab77e4b4 (patch) | |
| tree | e9c948de50360ed080b9be465e02759f7239edcc | |
| parent | 59341b52696923e45164e8b436906c61fe34e774 (diff) | |
| download | man-pages-13ad736507d1def4e2f24000b24bf5d7ab77e4b4.tar.gz | |
pidfd_open.2: Enhance the discussion of usage of fork() + pidfd_open()
After review comments from Christian and Daniel.
Reported-by: Christian Brauner <christian.brauner@ubuntu.com>
Reported-by: Daniel Colascione <dancol@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
| -rw-r--r-- | man2/pidfd_open.2 | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/man2/pidfd_open.2 b/man2/pidfd_open.2 index 7adad55c38..e29d6a2893 100644 --- a/man2/pidfd_open.2 +++ b/man2/pidfd_open.2 @@ -105,12 +105,32 @@ if (pid > 0) { /* If parent */ .EE .in .PP -Even if the child process has already terminated by the time of the +Even if the child has already terminated by the time of the .BR pidfd_open () -call, the returned file descriptor -is guaranteed to refer to the child because -the parent has not yet waited on the child -(and therefore, the child's ID has not been recycled). +call, its PID will not have been recycled and the returned +file descriptor will refer to the resulting zombie process. +Note, however, that this is guaranteed only if the following +conditions hold true: +.IP * 3 +the disposition of +.BR SIGCHLD +has not been explicitly set to +.BR SIG_IGN +(see +.BR sigaction (2)); +and +.IP * +the zombie process was not reaped elsewhere in the program +(e.g., either by an asynchronously executed signal handler or by +.BR wait (2) +or similar in another thread). +.PP +If these conditions don't hold true, +then the child process should instead be created using +.BR clone (2) +with the +.BR CLONE_PID +flag. .PP The .BR pidfd_send_signal (2) |
