-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel.system hangs if sub process spawns child #838
Comments
I updated the referred commit to fix a line ending issue. I will submit a pull request when I get an answer to how best to unit test this without hanging the unit tests |
I'm currently running into the same issue. It was working fine until now. I'm not sure what change affected it. I'm running on Java 1.8 and Jruby 1.7.9. |
I am having what seems to be the same or similar problem too. It was fine until I upgraded from jruby 1.6.7 to 1.7.12.. Some percentage of the time when I run a command via system() it will get stuck and wait for me to press enter (the process that had been running is gone but jruby is still waiting) command = "ls /" I'd love to know how to avoid this. Backticks isn't a complete solution for me since the process that is running could take up to 2 or 3 hours to run and I need to be able to see the output from it while it is executing. |
I am running my own compiled version of jruby with the fix I gave above. It is working great for me. |
Here's a stack from a stuck process I just hit: |
works on Linux ... maybe this was a Windows specific issue on JRuby 1.7.x (EOL) |
Just checked, #system still blocks on 9.1.9.0 + Windows 7 (x64). |
Hi, actually I'm working with JRuby 1.7.27 on Ubuntu 16.04 and it seems to have the same issue. In fact, the same thing happens with system, IO.popen, exec and net: ssh. |
@Marcofeli I'm guessing you would not have this problem on JRuby 9.2.x, since in 9k we reimplemented process management (for POSIX systems) using true native process functions. The rest of this issue is valid still, but duplicates many other issues that all have the same cause: we do not have native process management on JRuby yet. See also #4964 and others. |
Calling kernel.system with a command that spawns any other process causes the system call to not return until that spawned process is ended. Same as bug http://jira.codehaus.org/browse/JRUBY-4470.
File: testsystem.rb
MRI
JRuby
I tracked the problem down to an assumption in ShellLauncher that when a process is closed all handles to stdin/out will be closed, but in this case the sub process inherits handles (on windows anyway) and even though the process is complete (process.waitFor does not block) the runPidAndWait will sit waiting for the stream pumps to rejoin the main thread.
I have patched the function to make it work properly here halfnelson@33114bc
I still need to forcibly stop the input thread. That is another bug. I will file separately.
How do I go about writing a unit test for this, since the failure case means the code never returns? Spawn the request in another thread and add a timeout? Downside of that is it makes unit tests slower.
The text was updated successfully, but these errors were encountered: