the process invoked by backticks stays as zombie!

A

Artem Kazakov

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 ?
 
G

Glen Holcomb

[Note: parts of this message were removed to make it a legal post.]

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 ?
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.
 
A

Artem Kazakov

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?
 
A

Albert Schlef

Artem said:
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"`
 
D

Dave Bass

Albert said:
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.
 
J

John Carter

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 Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top