Skip to content
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

zombie processes #8

Open
zimbatm opened this issue Jun 10, 2011 · 5 comments
Open

zombie processes #8

zimbatm opened this issue Jun 10, 2011 · 5 comments

Comments

@zimbatm
Copy link

zimbatm commented Jun 10, 2011

Just found that issue, I don't have the time to investigate yet:

(master)⚡ % irb
ruby-1.8.7-p334 :001 > require 'open4'
 => true 
ruby-1.8.7-p334 :002 > Open4.spawn 'fsdsdsdfdf' rescue $!
 => #<Errno::ENOENT: No such file or directory - fsdsdsdfdf> 
ruby-1.8.7-p334 :003 > Process.waitall
 => [[46141, #<Process::Status: pid=46141,exited(1)>]] 
ruby-1.8.7-p334 :004 > 

If you don't wait for the pid, a zombie process is going to hang around

@noahgibbs
Copy link

Is this different from how things work in other libraries? I'm used to this problem with all similar Unix-based facilities...

@zimbatm
Copy link
Author

zimbatm commented Jun 24, 2011

Yes, people often get bitten by this posix particularity. In that case, it's Open4's responsibility to not leave zombies alive when the process dies.

@noahgibbs
Copy link

openface: shouldn't you be doing a detach or wait or something to harvest the child process?

@zimbatm
Copy link
Author

zimbatm commented Aug 2, 2011

Yes I could wait on the pid but I don't have access to it. It's not returned by the API and $? is empty because of Open4's double-fork.

@robertgrimm
Copy link

I've noticed this as well and agree with zimbatm's comments. It looks like the popen4 method should call 'Process.waitpid2(cid)' if the exec call raises an exception. It appears that a zombie process could also be left hanging around if the block, if used in block form, raises an exception. Perhaps move the existing Process.waitpid2 call to the ensure block?

Shouldn't it also ensure that all pipe endpoints are closed in this path? It looks like pw.last, pr.first and pe.first won't get closed in the original post's example.

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

No branches or pull requests

3 participants