Commit 1ffbf6d
authored
Get exit tests functioning on OpenBSD. (swiftlang#1352)
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. 🥳
<img width="1152" height="864" alt="openbsd"
src="https://github.com/user-attachments/assets/c97dbe39-6486-4953-9f3c-7c43c300b938"
/>
### Checklist:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.1 parent f276d25 commit 1ffbf6d
1 file changed
+7
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
116 | 123 | | |
117 | 124 | | |
118 | 125 | | |
| |||
0 commit comments