# \#system() hangs, child is defunct

**URL:** <https://www.ruby-forum.com/t/system-hangs-child-is-defunct/178147>\
**Category:** Ruby\
**Created:** [October 29, 2009, 8:20pm UTC](https://www.ruby-forum.com/t/system-hangs-child-is-defunct/178147 "2009-10-29T20:20:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tor\_Erik\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c57346/32.png) [@Tor\_Erik\_L](https://www.ruby-forum.com/u/Tor_Erik_L)\
**Post date:** [October 29, 2009, 8:20pm UTC](https://www.ruby-forum.com/t/system-hangs-child-is-defunct/178147/1 "2009-10-29T20:20:35Z")

</div>

Hi all,

I am trying to track down the source of an intermittent and tricky  
problem. The ruby version is 1.8.6 patchlevel 287. The OS is virtualized  
Gentoo, using the free Express image provided by Engine Y., so the  
system should be reasonably sane.

The problem is that a rake task hangs indefinitely. Attaching gdb to the  
ruby process, and getting a backtrace, I can see that it is hanging on a  
#system() call. The system call is used to invoke another Ruby process,  
but that Ruby child process has completed as expected, and is listed as  
.

If I understand correctly, this means that the parent Ruby process has  
failed to acknowledge that the child has exited. Could this be caused by  
errors in the parent’s Ruby code?

If anyone is familiar, the offending call takes place in  
rspec-1.2.8/lib/spec/rake/spectask.rb:176

Unfortunately, the issue is intermittent (it only hangs in some 20-30%  
of cases) and I have no idea of how to narrow it down any further. Any  
advice on how to proceed?

best regards,  
Tor Erik

---

<div class="post-metadata">

**Author:** ![Tor\_Erik\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c57346/32.png) [@Tor\_Erik\_L](https://www.ruby-forum.com/u/Tor_Erik_L)\
**Post date:** [October 31, 2009, 11:02pm UTC](https://www.ruby-forum.com/t/system-hangs-child-is-defunct/178147/2 "2009-10-31T23:02:21Z")

</div>

> Unfortunately, the issue is intermittent (it only hangs in some 20-30%  
> of cases) and I have no idea of how to narrow it down any further. Any  
> advice on how to proceed?

Try 1.8.7 or 1.8.x SVN trunk?  
-r

---

<div class="post-metadata">

**Author:** ![Tor\_Erik\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c57346/32.png) [@Tor\_Erik\_L](https://www.ruby-forum.com/u/Tor_Erik_L)\
**Post date:** [November 1, 2009, 1:12am UTC](https://www.ruby-forum.com/t/system-hangs-child-is-defunct/178147/3 "2009-11-01T01:12:47Z")

</div>

The thing is that this is a test setup, so we want to keep it just like  
production. I tried running the VM under VirtualBox instead of VMware  
Server, which seemed to make the problem go away for now. I would still  
like to know what was going on though.

---

<div class="post-metadata">

**Author:** ![Tor\_Erik\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c57346/32.png) [@Tor\_Erik\_L](https://www.ruby-forum.com/u/Tor_Erik_L)\
**Post date:** [November 2, 2009, 6:54pm UTC](https://www.ruby-forum.com/t/system-hangs-child-is-defunct/178147/4 "2009-11-02T18:54:21Z")

</div>

Tor Erik L. wrote:

> The thing is that this is a test setup, so we want to keep it just like  
> production. I tried running the VM under VirtualBox instead of VMware  
> Server, which seemed to make the problem go away for now. I would still  
> like to know what was going on though.

Looks like your next step might be to try and trudge through the code  
for #system  
or switch ruby versions, perhaps–1.9 seems more stable for me than  
others.  
-r
