the process invoked by backticks stays as zombie!

Discussion in 'Ruby' started by Artem Kazakov, May 21, 2008.

  1. 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 ?
     
    Artem Kazakov, May 21, 2008
    #1
    1. Advertising

  2. Artem Kazakov

    Glen Holcomb Guest

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

    On Wed, May 21, 2008 at 9:15 AM, 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 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)
     
    Glen Holcomb, May 21, 2008
    #2
    1. Advertising

  3. On May 22, 12:22 am, Glen Holcomb <> 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?
     
    Artem Kazakov, May 22, 2008
    #3
  4. 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/.
     
    Albert Schlef, May 22, 2008
    #4
  5. Artem Kazakov

    Dave Bass Guest

    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/.
     
    Dave Bass, May 22, 2008
    #5
  6. Artem Kazakov

    John Carter Guest

    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 :
    New Zealand
     
    John Carter, May 23, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leeor Chernov
    Replies:
    4
    Views:
    13,238
    Leeor Chernov
    Dec 15, 2005
  2. Brian
    Replies:
    1
    Views:
    324
    Keith Dart
    Dec 22, 2004
  3. Replies:
    0
    Views:
    520
  4. Iñaki Baz Castillo

    How to know if a process is zombie?

    Iñaki Baz Castillo, Dec 26, 2009, in forum: Ruby
    Replies:
    5
    Views:
    126
    Iñaki Baz Castillo
    Dec 26, 2009
  5. serge.john.swilting

    plouk zombie plouk zombie

    serge.john.swilting, Aug 19, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    202
    hudson
    Aug 20, 2003
Loading...

Share This Page