Signals an operating-system process by pid and stops it within a bounded time.
The pid is an integer the BEAM read from Port.info(port, :os_pid). It is passed to kill as a separate argument with no shell, so nothing is interpolated into a command line.
terminate/2 sends SIGTERM, waits up to the grace period for the process to exit, then sends SIGKILL and waits up to the same period again. It polls with kill -0 every 20 ms. A process that already exited is not signalled.
Summary
Functions
Returns true while pid exists (kill -0 succeeds).
Sends signal to pid. Returns :ok even when the process is gone.
Stops pid: SIGTERM, then SIGKILL after grace_ms. Returns :exited when the process exited after SIGTERM (or before it), :killed when SIGKILL ended it, and :still_running when it outlived both waits.
Waits up to ms milliseconds for pid to exit. Returns true when it is gone.
Types
Functions
@spec alive?(pos_integer()) :: boolean()
Returns true while pid exists (kill -0 succeeds).
@spec signal(pos_integer(), signal()) :: :ok
Sends signal to pid. Returns :ok even when the process is gone.
@spec terminate(pos_integer(), non_neg_integer()) :: :exited | :killed | :still_running
Stops pid: SIGTERM, then SIGKILL after grace_ms. Returns :exited when the process exited after SIGTERM (or before it), :killed when SIGKILL ended it, and :still_running when it outlived both waits.
@spec wait_gone(pos_integer(), non_neg_integer()) :: boolean()
Waits up to ms milliseconds for pid to exit. Returns true when it is gone.