Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Oct 4, 2025

This PR adjusts the implementation of exit tests on OpenBSD so that they correctly spawn child processes there.

Without this change, exit tests all abnormally terminate with exit code 127. ktrace and kdump report:

63170 swift-testingPackageTes CALL  sigaction(SIGHUP,0x932dd7e5ca0,0)
63170 swift-testingPackageTes STRU  struct sigaction { handler=SIG_DFL, mask=0<>, flags=0<> }
63170 swift-testingPackageTes RET   sigaction 0
63170 swift-testingPackageTes CALL  sigaction(SIGINT,0x932dd7e5ca0,0)
63170 swift-testingPackageTes STRU  struct sigaction { handler=SIG_DFL, mask=0<>, flags=0<> }
63170 swift-testingPackageTes RET   sigaction 0
[...]
63170 swift-testingPackageTes CALL  sigaction(SIGKILL,0x932dd7e5ca0,0)
63170 swift-testingPackageTes RET   sigaction -1 errno 22 Invalid argument
63170 swift-testingPackageTes CALL  exit(127)

OpenBSD is more strict in its handling of posix_spawnattr_setsigdefault() than our other target platforms. Specifically, the child process will self-terminate after forking but before execing if either SIGKILL or SIGSTOP is in the signal mask passed to that function. Other platforms silently ignore these signals (since their handlers cannot be set per POSIX anyway.)

With this change, exit tests function correctly and Swift Testing's test suite passes with zero issues on OpenBSD. 🥳

openbsd

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR adjusts the implementation of exit tests on OpenBSD so that they
correctly spawn child processes there.

Without this change, exit tests all abnormally terminate with exit code 127.
`ktrace` and `kdump` report:

```
63170 swift-testingPackageTes CALL  sigaction(SIGHUP,0x932dd7e5ca0,0)
63170 swift-testingPackageTes STRU  struct sigaction { handler=SIG_DFL, mask=0<>, flags=0<> }
63170 swift-testingPackageTes RET   sigaction 0
63170 swift-testingPackageTes CALL  sigaction(SIGINT,0x932dd7e5ca0,0)
63170 swift-testingPackageTes STRU  struct sigaction { handler=SIG_DFL, mask=0<>, flags=0<> }
63170 swift-testingPackageTes RET   sigaction 0
[...]
63170 swift-testingPackageTes CALL  sigaction(SIGKILL,0x932dd7e5ca0,0)
63170 swift-testingPackageTes RET   sigaction -1 errno 22 Invalid argument
63170 swift-testingPackageTes CALL  exit(127)
```

OpenBSD is more strict in its handling of `posix_spawnattr_setsigdefault()` than
our other target platforms. Specifically, the child process will self-terminate
after forking but before execing if either `SIGKILL` or `SIGSTOP` is in the
signal mask passed to that function. Other platforms silently ignore these
signals (since their handlers cannot be set per POSIX anyway.)

With this change, exit tests function correctly and Swift Testing's test suite
passes with zero issues on OpenBSD. 🥳
@grynspan grynspan added this to the Swift 6.x (main) milestone Oct 4, 2025
@grynspan grynspan self-assigned this Oct 4, 2025
@grynspan grynspan added bug 🪲 Something isn't working exit-tests ☠️ Work related to exit tests openbsd 🐡 OpenBSD support labels Oct 4, 2025
@grynspan
Copy link
Contributor Author

grynspan commented Oct 4, 2025

@3405691582 please review!

@grynspan grynspan merged commit 1ffbf6d into main Oct 4, 2025
24 checks passed
@grynspan grynspan deleted the jgrynspan/openbsd-exit-tests-127 branch October 4, 2025 03:06
@grynspan
Copy link
Contributor Author

grynspan commented Oct 4, 2025

@grynspan
Copy link
Contributor Author

grynspan commented Oct 4, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working exit-tests ☠️ Work related to exit tests openbsd 🐡 OpenBSD support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants