# The process invoked by backticks stays as zombie!

**URL:** <https://www.ruby-forum.com/t/the-process-invoked-by-backticks-stays-as-zombie/138281>\
**Category:** Ruby\
**Created:** [May 21, 2008, 5:16pm UTC](https://www.ruby-forum.com/t/the-process-invoked-by-backticks-stays-as-zombie/138281 "2008-05-21T17:16:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artem\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@Artem\_K](https://www.ruby-forum.com/u/Artem_K)\
**Post date:** [May 21, 2008, 5:16pm UTC](https://www.ruby-forum.com/t/the-process-invoked-by-backticks-stays-as-zombie/138281/1 "2008-05-21T17:16:06Z")

</div>

Hi Gurus 🙂

Here is the problem:  
I need to gather the output from an external program.  
So in my code I do:  
result \<\< `#{@caputackt} #{@channel} #{ackt}`

but the script stops at this line, and when I do ps I get  
ps aux | grep caput  
tyoma 5310 0.0 0.0 599780 460 s003 R+ 11:57PM 0:00.00  
grep caput  
tyoma 5305 0.0 0.0 0 0 s002 Z+ 11:57PM 0:00.00  
(caputackt)

so how is it possible ? and what to do ?

---

<div class="post-metadata">

**Author:** ![Artem\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@Artem\_K](https://www.ruby-forum.com/u/Artem_K)\
**Post date:** [May 21, 2008, 5:23pm UTC](https://www.ruby-forum.com/t/the-process-invoked-by-backticks-stays-as-zombie/138281/2 "2008-05-21T17:23:48Z")

</div>

On Wed, May 21, 2008 at 9:15 AM, Artem K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> grep caput  
> tyoma 5305 0.0 0.0 0 0 s002 Z+ 11:57PM 0:00.00  
> (caputackt)
> 
> so how is it possible ? and what to do ?

Always Kill You Children!

Basically you are spawning a child process here and your script is  
terminating before the child process does. Therefore you get a Zombie.  
At  
least that’s what it sounds like to me from your description.

–  
“Hey brother Christian with your high and mighty errand, Your actions  
speak  
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Artem\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@Artem\_K](https://www.ruby-forum.com/u/Artem_K)\
**Post date:** [May 22, 2008, 9:55am UTC](https://www.ruby-forum.com/t/the-process-invoked-by-backticks-stays-as-zombie/138281/3 "2008-05-22T09:55:54Z")

</div>

On May 22, 12:22 am, Glen H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Basically you are spawning a child process here and your script is  
> terminating before the child process does. Therefore you get a Zombie. At  
> least that’s what it sounds like to me from your description.  
> No, my script is not terminated before child.  
> It is waiting for child’s output, actually (that’s why I use  
> backquotes). And the problem is that it just keeps waiting forever,  
> even though the child process is dead, but it shows as “zombie”. So I  
> just do not get it, the parent is explicitly waiting for the  
> result(output), but the child is zombie.  
> Any ideas how to dig this problem?

---

<div class="post-metadata">

**Author:** ![Artem\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@Artem\_K](https://www.ruby-forum.com/u/Artem_K)\
**Post date:** [May 22, 2008, 12:56pm UTC](https://www.ruby-forum.com/t/the-process-invoked-by-backticks-stays-as-zombie/138281/4 "2008-05-22T12:56:12Z")

</div>

Albert S. wrote:

> Does it happen when you use the following line instead?
> 
> result \<\< `ls`

Hopefully not!

Maybe the child process thinks it’s finished, but Ruby is still waiting  
for it to return a value. Or maybe the child is waiting for some  
resource it can’t get, for some reason. Or has been blocked by some  
other process (e.g. via file locking).

If it were my problem I’d try a dummy child process and make sure that  
works, i.e. something that just prints a string to stdout and returns  
zero. Then I’d gradually add functionality to it until it stopped  
working.

---

<div class="post-metadata">

**Author:** ![Artem\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@Artem\_K](https://www.ruby-forum.com/u/Artem_K)\
**Post date:** [May 22, 2008, 11:16am UTC](https://www.ruby-forum.com/t/the-process-invoked-by-backticks-stays-as-zombie/138281/5 "2008-05-22T11:16:49Z")

</div>

Artem K. wrote:

> Hi Gurus 🙂
> 
> Here is the problem:  
> I need to gather the output from an external program.  
> So in my code I do:  
> result \<\< `#{@caputackt} #{@channel} #{ackt}`
> 
> but the script stops at this line, and when I do ps I […]

Does it happen when you use the following line instead?

result \<\< `ls`

…and when you use the following?

result \<\< `ruby -e "puts 123"`

---

<div class="post-metadata">

**Author:** ![Artem\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@Artem\_K](https://www.ruby-forum.com/u/Artem_K)\
**Post date:** [May 23, 2008, 5:14am UTC](https://www.ruby-forum.com/t/the-process-invoked-by-backticks-stays-as-zombie/138281/6 "2008-05-23T05:14:11Z")

</div>

On Thu, 22 May 2008, Glen H. wrote:

> Always Kill You Children!  
> Not really.

The perlfunc man page said it best…

```
            If you "fork" without ever waiting on your children,
            you will accumulate zombies. On some systems, you can
            avoid this by setting $SIG{CHLD} to "IGNORE". See also
            perlipc for more examples of forking and reaping
            moribund children.

```

Basically a Zombie process is a place to store the exit status whilst  
waiting for the parent to do a “wait” on the child and collect it.

Normally it’s not a problem with backtick, backtick usually waits on  
the children and collects the exit status into $? for you.

Thus there is something odd ball about your kiddies…

> ```
> result << `#{@caputackt} #{@channel} #{ackt}`
> 
> ```

You’re sort of asking the wrong question here. ie.  
result \<\< `some string`  
works simply and as expected, no raging zombies involved.

Your problem lies in what “#{@caputackt} #{@channel} #{ackt}” expands  
to and you aren’t telling us what that is!

Tell us that, and we’ll tell you how to fix the problem.

John C. Phone : (64)(3) 358 6639  
Tait Electronics Fax : (64)(3) 359 4632  
PO Box 1645 Christchurch Email : removed\_email\_address@domain.invalid  
New Zealand
