The process invoked by backticks stays as zombie!

Hi Gurus :slight_smile:

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 ?

On Wed, May 21, 2008 at 9:15 AM, Artem K. [email protected]
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)

On May 22, 12:22 am, Glen H. [email protected] 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?

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.

Artem K. wrote:

Hi Gurus :slight_smile:

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"

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 : [email protected]
New Zealand

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs