[Midnightbsd-cvs] [MidnightBSD/mports] 243a26: magus: time out make targets that hang (#1215)

Lucas Holt noreply at github.com
Fri Sep 11 14:40:25 EDT 2026


  Branch: refs/heads/master
  Home:   https://github.com/MidnightBSD/mports
  Commit: 243a26c9d799ad937c261fd31179422fe90fcfa0
      https://github.com/MidnightBSD/mports/commit/243a26c9d799ad937c261fd31179422fe90fcfa0
  Author: Lucas Holt <luke at foolishgames.com>
  Date:   2026-09-11 (Fri, 11 Sep 2026)

  Changed paths:
    M Tools/lib/Magus/Config.pm
    M Tools/lib/Magus/PortTest.pm
    M Tools/magus/config.yaml.example
    A Tools/t/magus-porttest-timeout.t

  Log Message:
  -----------
  magus: time out make targets that hang (#1215)

`Magus::PortTest::_run_make` used a bare blocking `system()`, so any
port whose make target never returns takes a worker out of service
indefinitely. On run 646, `lang/php84`'s deadlocked test suite held
worker 1 on m4164 for seven days — nothing in the slave noticed or
intervened. #1213 and #1214 fix that particular port; this fixes the
class of failure.

## Change

Run make in its own session (`fork` + `setsid`) with a `SIGALRM`
watchdog in the parent. On expiry the whole process group gets `TERM`
then `KILL`, so children a hung build has spawned go away with it. The
log is annotated and the phase is reported as `MakeTimeout` rather than
a generic non-zero exit.

The limit is `MakeTimeout` **seconds**, default `86400` to leave room
for llvm- and rust-sized builds, with per-target overrides in
`MakeTimeouts` (`test: 7200`). `0` disables the watchdog.

Two details worth a reviewer's attention:

- **`local $SIG{CHLD} = 'DEFAULT'` is load-bearing.** `magus.pl:87`
installs a `waitpid(-1, WNOHANG)` reaper that the worker inherits;
without holding it off, it races our `waitpid` and we lose make's exit
status.
- `exec(@cmd)` replaces `system($string)`, dropping the shell that used
to sit between magus and make. `$MAKE` is a bare path
(`Mport::Globals:15`), so no quoting behavior is lost.

## Verification

`perl -c` plus a harness driving the real
`_run_make`/`_reap_group`/`_timeout_for` bodies:

| case | result |
|---|---|
| command hangs, spawns a background child | returns false at the limit,
`timed_out` set, log annotated, no surviving processes |
| `exit 0` | returns true, `$? >> 8 == 0` |
| `exit 3` | returns false, `$? >> 8 == 3`, with the indiscriminate
SIGCHLD reaper installed |
| `_timeout_for` | `test` → 7200, `build` → 86400 |

Not exercised against a live cluster — I have no slave here. Picking up
the change needs a slave restart.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_017JRCQA17KgZSRk2vV96wbT

## Summary by Sourcery

Add bounded execution and process cleanup for Magus make targets so hung
builds fail clearly without taking workers out of service.

New Features:
- Add configurable watchdog timeouts for individual make targets,
including per-target overrides and the ability to disable timeouts.
- Report timed-out builds distinctly and preserve timeout diagnostics
alongside parsed port errors.

Bug Fixes:
- Prevent hung make targets and their descendant processes from
indefinitely occupying Magus workers.
- Preserve make exit statuses despite the worker's inherited SIGCHLD
reaper.

Enhancements:
- Run make targets in isolated process sessions and escalate termination
from TERM to KILL when needed.
- Replace shell-based make invocation with direct argument execution
while retaining build logging and environment settings.

Tests:
- Add coverage for timeout configuration, exit-status preservation,
process-group cleanup, termination escalation, logging, and diagnostic
merging.

---------

Signed-off-by: Lucas Holt <luke at foolishgames.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply at anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot at users.noreply.github.com>



To unsubscribe from these emails, change your notification settings at https://github.com/MidnightBSD/mports/settings/notifications



More information about the Midnightbsd-cvs mailing list