process that has died, but whose parent has not yet performed a wait() to obtain its termination status).
(1)The kill() system with sig argument is specified as 0 (the so-called null signal),
exist. If the call fails with the error EPERM (meaning the process exists, but we don’t have permission to send a signal to it) or succeeds (meaning we do have permission
to send a signal to the process), then we know that the process exists.
(2)The wait() system calls: They can be employed only if the monitored process is a child of the caller.
(3)Semaphores and exclusive file locks: If the process that is being monitored continuously holds a semaphore or a file lock, then, if we can acquire the semaphoreor lock, we know the process has terminated.
(4)IPC channels such as pipes and FIFOs: We set up the monitored process so that it holds a file descriptor open for writing on the channel as long as it is alive.
Meanwhile, the monitoring process holds open a read descriptor for the chan-nel, and it knows that the monitored process has terminated when the write
end of the channel is closed (because it sees end-of-file).
(5)The /proc/PID interface: For example, if a process with the process ID 12345 exists, then the directory /proc/12345 will exist, and we can check this using a
call such as stat().
All of these techniques, except the first and the last, are unaffected by recycling of process IDs.
1124



被折叠的 条评论
为什么被折叠?



