Skip to content

Conversation

jakepetroules
Copy link
Contributor

The approach used by Subprocess to monitor subprocess termination on Linux is fundamentally flawed as it calls waitid with P_ALL, and WEXITED without WNOWAIT, which will end up reaping pids that were spawned outside the Subprocess library.

Use an implementation more like swift-testing does for wait tests, which doesn't suffer from this issue.

Closes #82

jakepetroules added a commit that referenced this pull request Jun 17, 2025
Process termination monitoring is started asynchronously with the closure which receives the Execution, meaning any use of Execution in the body to send signals, etc., may send them to a pid which no longer refers to the original process. The cleanup handler may also run after the process has already terminated. This compounds with the fix for #82 (#83) to fully resolve the race conditions.
jakepetroules added a commit that referenced this pull request Jun 18, 2025
Process termination monitoring is started asynchronously with the closure which receives the Execution, meaning any use of Execution in the body to send signals, etc., may send them to a pid which no longer refers to the original process. The cleanup handler may also run after the process has already terminated. This compounds with the fix for #82 (#83) to fully resolve the race conditions.
… processes spawned by other means

The approach used by Subprocess to monitor subprocess termination on Linux is fundamentally flawed as it calls waitid with P_ALL, and WEXITED without WNOWAIT, which will end up reaping pids that were spawned outside the Subprocess library.

Use an implementation more like swift-testing does for wait tests, which doesn't suffer from this issue.

Closes #82
@jakepetroules jakepetroules merged commit ca05b23 into main Jun 21, 2025
21 checks passed
@jakepetroules jakepetroules deleted the eng/PR-term branch June 21, 2025 06:09
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.

Process termination monitoring implementation on Linux conflicts with processes spawned by other means

2 participants