Pdeathsig is almost never what you want

recall.ai

27 points by timetoogo 3 months ago


scottlamb - 3 months ago

Feeling deja vu. There was a previous discussion of this article, though it had a different title and URL then.

https://news.ycombinator.com/item?id=43268713

https://web.archive.org/web/20250306200642/https://www.recal...

nine_k - 3 months ago

Well, yes, the difference between a "process" and a "thread" under Linux is that after a fork() the new "process" has COW data pages, while a new "thread" just gets access to the same data pages. Otherwise they are basically the same thing. No wonder that a Chromium process spawned from a thread lists that thread as a parent process, and gets reaped when the thread exits, whether it's the main thread, or some other thread.

And no, listing the main thread automatically as the parent won't be significantly more logical. The main thread can detach spawned threads and then exit via thread_exit() (not regular exit()), and then the spawned threads will continue to run. So the Linux kernel does the most straightforward thing. The same PDEATHSIG approach would likely work if the spawning thread then reparented the Chromium child process to to the main thread.

mperham - 3 months ago

I use Pdeathsig but with SIGTERM, not SIGKILL, to ensure clean shutdown of a child Redis process. Seems crazy to use SIGKILL.

cryptonector - 3 months ago

The it should be called PTDEATHSIG not PDEATHSIG, and there should be a way to ask for the child to get killed when the parent _process_ exits -- that is (would be) very useful.

mmastrac - 3 months ago

There was a recent blog post on this exact issue from another company wasn't there?

https://news.ycombinator.com/item?id=43153901, I think