Skip to content

Reap only own children when GAP is embedded or HPC-GAP - #138

Open
fingolfin wants to merge 3 commits into
masterfrom
mh/embedded-child-reaping
Open

fingolfin wants to merge 3 commits into
masterfrom
mh/embedded-child-reaping

Conversation

@fingolfin

@fingolfin fingolfin commented Sep 7, 2026

Copy link
Copy Markdown
Member

The SIGCHLD handler reaps every child with waitpid(-1) and queues the statuses. That breaks any other party managing children in the same process: HPC-GAP's signal thread (issue #5), and programs embedding GAP such as julia, whose libuv reaps its subprocesses per pid and hangs forever once io has stolen a status (GAP.jl#902).

In those two settings install no handler; instead keep a registry of the children created by IO_fork and wait for them with waitpid(pid), on demand. IO_IgnorePid marks a registered child to be reaped whenever io next deals with children, and IO_WaitPid(-1, ...) polls the registry. Standalone GAP keeps the handler and the FIFO unchanged.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

CC @lgoettgens

Progress towards issue #5 (I am not sure when exactly we can declare that one to be resolved)

The SIGCHLD handler reaps every child with waitpid(-1) and queues the
statuses. That breaks any other party managing children in the same
process: HPC-GAP's signal thread (issue #5), and programs embedding GAP
such as julia, whose libuv reaps its subprocesses per pid and hangs
forever once io has stolen a status (GAP.jl#902).

In those two settings install no handler; instead keep a registry of the
children created by IO_fork and wait for them with waitpid(pid), on
demand. IO_IgnorePid marks a registered child to be reaped whenever io
next deals with children, and IO_WaitPid(-1, ...) polls the registry.
Standalone GAP keeps the handler and the FIFO unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comment thread src/io.c Outdated
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ChrisJefferson

Copy link
Copy Markdown
Member

So I'm happy with this. I remember (but I've forgotten the details!) that how io an gap core handle children was a bit of a mess, and it's hard to pick apart, but there are tests which should catch obvious breakage (like never cleaning up any children)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants