News for hackers. Stuff that matters.
Re:Signals in Prod: Dangers and Pitfalls by 0xbadcafebee on Monday October 03, 2022 @11:16PM (#33076365)
Completely unrelated, but useful: POSIX kill (or kill()) with signal 0 is a portable way to check if a process controllable by the current user is alive.
Re:Signals in Prod: Dangers and Pitfalls by memco on Tuesday October 04, 2022 @01:40AM (#33076985)
Could you elaborate on what makes that a great way to check and what advantage that has over other methods?
Re:Signals in Prod: Dangers and Pitfalls by saagarjha on Tuesday October 04, 2022 @01:45AM (#33077011)
It doesn’t do anything but returns a result based on the existence of the process and your ability to signal it, which makes it a sort of “dry run” of sorts. Note that such a check is inherently racy, though.
Re:Signals in Prod: Dangers and Pitfalls by LunaSea on Tuesday October 04, 2022 @02:38AM (#33077248)
> Note that such a check is inherently racy, though.

Do you mean in a kind of "time of check vs. time of use" kind of way?

I would suppose that if the answer is negative that would at least stay true no?

Re:Signals in Prod: Dangers and Pitfalls by saagarjha on Tuesday October 04, 2022 @05:59AM (#33078265)
Yes. If the process exits (and is perhaps replaced by something else!) in between the two checks you will take actions based on stale information.