mirror of https://github.com/mkerrisk/man-pages
pidfd_open.2: Explain how pidfd_open() can be used to with fork()
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
6059228b26
commit
59341b5269
|
@ -91,6 +91,27 @@ is Linux specific.
|
||||||
Currently, there is no glibc wrapper for this system call; call it using
|
Currently, there is no glibc wrapper for this system call; call it using
|
||||||
.BR syscall (2).
|
.BR syscall (2).
|
||||||
.PP
|
.PP
|
||||||
|
The following code sequence can be used to obtain a file descriptor
|
||||||
|
for the child of
|
||||||
|
.BR fork (2):
|
||||||
|
.PP
|
||||||
|
.in +4n
|
||||||
|
.EX
|
||||||
|
pid = fork();
|
||||||
|
if (pid > 0) { /* If parent */
|
||||||
|
pidfd = pidfd_open(pid, 0);
|
||||||
|
...
|
||||||
|
}
|
||||||
|
.EE
|
||||||
|
.in
|
||||||
|
.PP
|
||||||
|
Even if the child process 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).
|
||||||
|
.PP
|
||||||
The
|
The
|
||||||
.BR pidfd_send_signal (2)
|
.BR pidfd_send_signal (2)
|
||||||
system call can be used to send a signal to the process referred to by
|
system call can be used to send a signal to the process referred to by
|
||||||
|
|
Loading…
Reference in New Issue