You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After running many small processes (one after another, not concurrently) subprocesses throws the following error and hangs until manually killed.
Failed to spawn the new process with underlying error: UnderlyingError(rawValue: 24)
To Reproduce
Steps to reproduce the behavior:
Call the run method exposed by Subprocess a few hundred (maybe thousands of) times and it'll eventually throw the error.
I'm specifically calling the run method within an In-Process Vapor Queue / Job once a minute to monitor a running service
Expected behavior
For the subprocess command to not fail and the program to not hang
Environment (please complete the following information):
OS:
Linux version 6.12.34+rpt-rpi-v8 (aarch64-linux-gnu-gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40)
Swift version:
Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: aarch64-unknown-linux-gnu
and
Swift version 6.1.3 (swift-6.1.3-RELEASE)
Target: aarch64-unknown-linux-gnu
Additional context
I did some googling and I think error 24 might be related to exceeding the maximum number of open file descriptors in linux. Is it possible subprocess isn't properly closing the process?
Note
All of the tests pass except for SubprocessUnixTests.testConcurrentRun(). This test results in a hang every time it's ran. I think we hit the 1024 file descriptor limit (on linux as noted in the comments) and instead of the thrown error (.spawnError) canceling the task, it hangs indefinitely instead.
Describe the bug
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Environment (please complete the following information):
and
Additional context
Note
All of the tests pass except for
SubprocessUnixTests.testConcurrentRun(). This test results in a hang every time it's ran. I think we hit the 1024 file descriptor limit (on linux as noted in the comments) and instead of the thrown error (.spawnError) canceling the task, it hangs indefinitely instead.