Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > the process invoked by backticks stays as zombie!

Reply
Thread Tools

the process invoked by backticks stays as zombie!

 
 
Artem Kazakov
Guest
Posts: n/a
 
      05-21-2008
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 ?

 
Reply With Quote
 
 
 
 
Glen Holcomb
Guest
Posts: n/a
 
      05-21-2008
[Note: parts of this message were removed to make it a legal post.]

On Wed, May 21, 2008 at 9:15 AM, Artem Kazakov <(E-Mail Removed)> 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 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.

--
"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)

 
Reply With Quote
 
 
 
 
Artem Kazakov
Guest
Posts: n/a
 
      05-22-2008
On May 22, 12:22 am, Glen Holcomb <(E-Mail Removed)> 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?
 
Reply With Quote
 
Albert Schlef
Guest
Posts: n/a
 
      05-22-2008
Artem Kazakov 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"`




--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Dave Bass
Guest
Posts: n/a
 
      05-22-2008
Albert Schlef 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.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
John Carter
Guest
Posts: n/a
 
      05-23-2008
On Thu, 22 May 2008, Glen Holcomb 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 Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : http://www.velocityreviews.com/forums/(E-Mail Removed)
New Zealand


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
handle a pipe (|) character inside backticks? Chris McMahon Ruby 2 10-19-2006 09:30 PM
Excel.exe Process stays open in my "Task Manager" (C# ASP.Net Development) Leeor Chernov ASP .Net 4 12-15-2005 08:30 AM
Lazy fun: Make unary minus silence stderr for backticks Sam Stephenson Ruby 9 11-07-2005 03:36 PM
taint: system vs. backticks and permissions Kristina Clair Perl 0 08-27-2004 03:54 PM
Backticks: What up? Steven Brent Python 6 04-28-2004 03:40 PM



Advertisments