> Вот решили проблему в ядре 5.2.
> В системный вызов clone() добавлен флаг CLONE_PIDFD, при указании которого родительскому
> процессу возвращается файловых дескриптор "pidfd", отождествлённый с созданным дочерним
> процессом. Данный файловый дескриптор, например, можно использовать для отправки сигналов
> без опасения столкнуться с состоянием гонки
> И pidfd_send_signal
> Дают возможность слать сигналы без гонок.Молодцы! Всего на 8 лет отстали ;)
man pdfork
> Process descriptors are special file descriptors that represent
> processes, and are created using pdfork(),
> pdgetpid() queries the process ID (PID) in the process descriptor fd.
> pdkill() is functionally identical to kill(2), except that it accepts a process descriptor, fd, rather than a PID.
man procdesc
NAME
procdesc – process descriptor facilityDESCRIPTION
procdesc is a file-descriptor-oriented interface to process signalling
and control, which supplements historic UNIX fork(2), kill(2), and
wait4(2) primitives with new system calls such as pdfork(2), pdkill(2),
and pdwait4(2). procdesc is designed for use with capsicum(4), replacing
process identifiers with capability-oriented references. However, it can
also be used independently of capsicum(4), displacing PIDs, which may
otherwise suffer from race conditions. Given a process descriptor, it is
possible to query its conventional PID using pdgetpid(2).
SEE ALSO
fork(2), kill(2), pdfork(2), pdgetpid(2), pdkill(2), pdwait4(2),
kqueue(2), wait4(2), capsicum(4)
HISTORY
procdesc first appeared in FreeBSD 9.0, and was developed at the
University of Cambridge.