From 56cf9e8eec3bdc0ce44efeda373de9d6b825ea1e Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 28 Jan 2022 17:13:41 -0300 Subject: linux: Add pidfd_send_signal This was added on Linux 5.1(3eb39f47934f9d5a3027fe00d906a45fe3a15fad) as a way to avoid the race condition of using kill (where PID might be reused by the kernel between between obtaining the pid and sending the signal). If the siginfo_t argument is NULL then pidfd_send_signal is equivalent to kill. If it is not NULL pidfd_send_signal is equivalent to rt_sigqueueinfo. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- sysdeps/unix/sysv/linux/sys/pidfd.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sysdeps/unix/sysv/linux/sys') diff --git a/sysdeps/unix/sysv/linux/sys/pidfd.h b/sysdeps/unix/sysv/linux/sys/pidfd.h index 7194fc2..7bbc5e4 100644 --- a/sysdeps/unix/sysv/linux/sys/pidfd.h +++ b/sysdeps/unix/sysv/linux/sys/pidfd.h @@ -38,4 +38,12 @@ extern int pidfd_open (__pid_t __pid, unsigned int __flags) __THROW; extern int pidfd_getfd (int __pidfd, int __targetfd, unsigned int __flags) __THROW; +/* Sends the signal SIG to the target process referred by the PIDFD. If + INFO points to a siginfo_t buffer, it will be populated. + + The FLAGS argument is reserved for future use, it must be specified + as 0. */ +extern int pidfd_send_signal (int __pidfd, int __sig, siginfo_t *__info, + unsigned int __flags) __THROW; + #endif /* _PIDFD_H */ -- cgit v1.1