Minor doc update: "orphan" processes #14271
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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