Skip to content

Conversation

@adamwight
Copy link
Contributor

This patch makes two small changes to the documentation:

First, "zombie" processes are in a terminated state and will appear in "ps" output in "Z" state. The problem described in our documentation seems to actually be about the "orphan" condition, in which a process continues running after its parent terminates. Most unix systems will reparent the process with PID 1 but this can vary, but there is no convention that the process should stop unless it has been wired using eg. "prctl" to detect a terminated parent. The distinction between zombie and orphan is important because it means the child is still active.

Second, our suggestion that the child process should detect stdin closure is a good workaround but is not generally true for applications that aren't doing their work on stdio. I've tried to clean up the text around the example shell script to clarify that developers are free to use this technique to detect parent termination, but it's not the rule for polite unix applications. Hijacking stdin also comes with some drawbacks as is already mentioned.

I'm not suggesting a different workaround at the moment—there is a linux-specific technique of using "prctl" which is demonstrated in https://groups.google.com/g/elixir-lang-core/c/yiepKrcEniU , however this isn't portable.

See #7495 and #9171

This patch makes two small changes to the documentation:

First, "zombie" processes are in a terminated state and will appear in
"ps" output in "Z" state.  The problem described in our documentation
seems to actually be about the "orphan" condition, in which a process
continues running after its parent terminates.  Most unix systems will
reparent the process with PID 1 but this can vary, but there is no
convention that the process should stop unless it has been wired using
eg. "prctl" to detect a terminated parent.  The distinction between
zombie and orphan is important because it means the child is still
active.

Second, our suggestion that the child process should detect stdin
closure is a good workaround but is not generally true for
applications that aren't doing their work on stdio.  I've tried to
clean up the text around the example shell script to clarify that
developers are free to use this technique to detect parent
termination, but it's not the rule for polite unix applications.
Hijacking stdin also comes with some drawbacks as is already
mentioned.

I'm not suggesting a different workaround at the moment—there is a
linux-specific technique of using "prctl" which is demonstrated in
https://groups.google.com/g/elixir-lang-core/c/yiepKrcEniU ,
however this isn't portable.

See elixir-lang#7495 and elixir-lang#9171
@josevalim josevalim merged commit b393dcc into elixir-lang:main Feb 17, 2025
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@adamwight adamwight deleted the orphan-doc branch February 17, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants