Skip to content
Merged
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: 14 additions & 0 deletions lib/pythonx/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ defmodule Pythonx.Application do

@impl true
def start(_type, _args) do
enable_sigchld()

children = [
Pythonx.Janitor
]
Expand All @@ -26,4 +28,16 @@ defmodule Pythonx.Application do
else
defp maybe_uv_init(), do: :noop
end

defp enable_sigchld() do
# Some APIs in Python, such as subprocess.run, wait for a child
# OS process to finish. On Unix, this relies on `waitpid` C API,
# which does not work properly if SIGCHLD is ignored, resulting
# in infinite waiting. ERTS ignores the signal by default, so we
# explicitly restore the default handler.
case :os.type() do
{:win32, _osname} -> :ok
{:unix, _osname} -> :os.set_signal(:sigchld, :default)
end
end
end
Loading