Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/elixir/lib/port.ex
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,22 @@ defmodule Port do
reimplementing core part of the Runtime System, such as the `:user` and
`:shell` processes.

## Zombie operating system processes
## Orphan operating system processes

A port can be closed via the `close/1` function or by sending a `{pid, :close}`
message. However, if the VM crashes, a long-running program started by the port
will have its stdin and stdout channels closed but **it won't be automatically
terminated**.

While most Unix command line tools will exit once its communication channels
are closed, not all command line applications will do so. You can easily check
While some Unix command line tools will exit once its parent process
terminates, not all command line applications will do so. You can easily check
this by starting the port and then shutting down the VM and inspecting your
operating system to see if the port process is still running.

While we encourage graceful termination by detecting if stdin/stdout has been
closed, we do not always have control over how third-party software terminates.
In those cases, you can wrap the application in a script that checks for stdin.
Here is such script that has been verified to work on bash shells:
We do not always have control over how third-party software terminates.
If necessary, one workaround is to wrap the child application in a script that
checks whether stdin has been closed. Here is such a script that has been
verified to work on bash shells:

#!/usr/bin/env bash

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ defmodule System do
ports guarantee stdin/stdout devices will be closed but it does not
automatically terminate the program. The documentation for the
`Port` module describes this problem and possible solutions under
the "Zombie processes" section.
the "Orphan operating system processes" section.

> #### Windows argument splitting and untrusted arguments {: .warning}
>
Expand Down
4 changes: 2 additions & 2 deletions lib/mix/lib/mix/tasks/cmd.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule Mix.Tasks.Cmd do

* `--cd` *(since v1.10.4)* - the directory to run the command in

## Zombie operating system processes
## Orphan operating system processes

Beware that the Erlang VM does not terminate child processes
when it shuts down. Therefore, if you use `mix cmd` to start
Expand All @@ -48,7 +48,7 @@ defmodule Mix.Tasks.Cmd do

A solution is to make sure the child processes listen to the
standard input and terminate when standard input is closed.
We discuss this topic at length in the "Zombie operating system processes"
We discuss this topic at length in the "Orphan operating system processes"
of the `Port` module documentation.
"""

Expand Down