| Summary: | Feature request: fix wait-built to allow waiting for ANY process, not just the current shell's child | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Mikhail T. <freebsd-2024> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed Works As Intended | ||
| Severity: | Affects Some People | CC: | jilles, mi |
| Priority: | --- | ||
| Version: | CURRENT | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
Mikhail T.
2015-01-21 00:21:37 UTC
Or, maybe, the wait()-function found in libc should be rewritten to use kqueue() instead of the wait() system call? That would expand the functionality of all traditional wait-users at once... Thank you very much, Jan, for your work and patience. Argh, my comment #2 was meant for an entirely different bug... As noted by the pwait(1) man page, pwait is not a replacement for the wait builtin, since it can wait for a process to terminate and show the exit status but cannot clean up zombies or state on the parent process. Therefore, I don't think the wait builtin should be changed -- if a script wants to wait for an unrelated process, it can use pwait. rc.subr already uses pwait when waiting for a service to stop. This does not work optimally because pwait waits for a process to terminate, while rc.subr wants to wait for the zombie to be reaped by the parent such as init (by waiting until kill -0 PID fails). I don't think the wait builtin should be changed due to its dual role of waiting and reporting exit status on one hand and cleaning up associated status on the other hand. (In reply to Jilles Tjoelker from comment #5) > role of waiting and reporting exit status on one hand and cleaning up associated status I still think, sh's wait can play both roles for all processes and only the latter -- the cleaning up -- role for the sh's children. Without breaking any existing scripts... POSIX is clear that wait should report status 127 when a process ID is not a child of the current shell environment, and I expect that there are scripts which rely on that. Apart from that, using the same command with the same syntax to do something quite different seems confusing. |