Perl's signal and child-process model: what we found (for fixing at Perl's level)

The one place for these findings. The user asked on 2026-11-01 that everything we learn about deficiencies of Perl's signal model be collected here, so that it can eventually be fixed in Perl itself. Add new findings here, with their evidence; other docs should point here instead of repeating them.

Updated 2026-11-01. Tested on Perl 5.38.2 (Debian/Ubuntu build, threaded), glibc 2.39, Linux 6.18. The probe scripts are in the old Project's files, not shipped.

Words used:

Each finding says what happens, how we know (tested here, or reasoned), what it costs us, and what Perl could change. ❰BUG❱ marks a defect.

1. Delivering signals to Perl code

S1. POSIX::sigaction installs immediate handlers by default, %SIG deferred ones.

S2. ❰BUG❱ (in our executor, caused by S1) An immediate handler corrupts Perl's heap.

S3. A deferred handler that becomes due just before a blocking call runs only after that call returns: a lost wake-up.

S4. kill to the program's own pid runs pending deferred handlers at once.

S5. %SIG installs handlers without SA_RESTART.

S6. sleep and select return early whenever a handled signal arrives, even with SA_RESTART.

S7. A deferred handler can run between the kernel's reaping of a child and the moment Perl code stores that status.

2. Children's exit statuses

C1. $SIG{CHLD} = 'IGNORE' discards the statuses of all children of the process.

C2. There is no reliable way to stop other code from reaping our children.

C3. ❰BUG❱ in Perl: assigning to ${^CHILD_ERROR_NATIVE} sets $^C instead.

C4. waitpid sets $? to -1 also when WNOHANG finds nothing.

3. What children inherit

I1. SIGFPE: Perl ignores it for itself, and restores the original setting only in its own exec.

I2. Signals the Perl program ignores are ignored in its children too.

I3. For reference (documented, followed by us): system ignores SIGINT and SIGQUIT in the parent while it waits.

4. Where these came from

5. Candidates for reports to Perl (perlbug), none filed yet

  1. C3: assigning to ${^CHILD_ERROR_NATIVE} sets $^C (confirmed in blead's mg.c).
  2. S1: document prominently that POSIX::sigaction handlers are immediate unless safe(1); S2 shows the consequence.
  3. S3: no way to wait for a deferred signal without a lost wake-up; ask for a signal-to-fd mode or for atomic waits.
  4. C2: a "claim this pid" facility, generalizing PL_pidstatus.
  5. I1: expose PL_sigfpe_saved.
  6. C4 and S5, S6: documentation, or options.