3 ms·
For ages now, I've wanted NT-style process handles. open(2)ing a process (maybe via its proc directory) should keep the corresponding process alive, even if as
by quotemstr 9y ago
For ages now, I've wanted NT-style process handles. open(2)ing a process (maybe via its proc directory) should keep the corresponding process alive, even if as a zombie. This way, you'd be able to write perfectly robust versions of pkill without annoying TOCTOU PID reuse races.
Linus has rejected this mechanism due to the ability of an outstanding process handle to prevent process reclaim, permitting users to fill the process table --- but I think this argument is bogus: users not constrained by RLIMIT_NPROC can do that already, and we could count process handles against RLIMIT_NPROC.
Bonus points: allow operations like kill, ptrace, status-reading, etc., via the process handle FD instead of PID-accepting syscalls. This way, you'd be able to pass the FD around as a credential.
Even more bonus points: select(2) support for the FD for easy process death monitoring.
- nanny 9y agoThe argument is not bogus, but it may not be realistic. But this is: https://randomascii.wordpress.com/2018/02/11/zombie-processes-are-eating-your-memory/ https://randomascii.wordpress.com/2018/02/11/zombie-processe...
- quotemstr 9y agoSo? How is that different from leaking any other kind of resource? There's nothing special about processes.
- JdeBP 9y agoWe've talked before about FreeBSD's process descriptors and EVFILT_PROC kevents, ne?
- loeg 9y agoProcess descriptors are unfortunately a little incomplete -- pdwait() was never implemented. They don't seem to be getting much use.
- crest 9y agoYou don't need pdwait(). You can watch the process descriptor with kqueue to get the process exit status look for EVFILT_PROCDESC in https://www.freebsd.org/cgi/man.cgi?kevent https://www.freebsd.org/cgi/man.cgi?kevent.