Skip to content

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

Merged
fingolfin merged 3 commits into
masterfrom
mh/embedded-child-reaping
Sep 18, 2026
Merged

fingolfin merged 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 [email protected]

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 <[email protected]>
Comment thread src/io.c Outdated
@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)

@fingolfin
fingolfin merged commit c228b79 into master Sep 18, 2026
9 checks passed
@fingolfin
fingolfin deleted the mh/embedded-child-reaping branch September 18, 2026 13:39
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