in reply to Re^2: system() returns -1 with $SIG{CHLD}?
in thread system() returns -1 with $SIG{CHLD}?

Why are you using $SIG{CHLD} with system? You shouldn't wait for a child launched using system.

This was just a sample piece of code distilled down from a much larger perl program. In the big program, I'm running commands in the background, that take an arbitrary amount of time to complete. I don't want to be leaving any zombie processes around, so I used wait() with $SIG{CHLD} to mitigate this.

Should I be doing something differently here, or should I be responsible for managing the handling of $SIG{CHLD} whenever I want to run a system() command?

update: The zombies are left after forking a background process, not using system. I didn't make that clear

  • Comment on Re^3: system() returns -1 with $SIG{CHLD}?

Replies are listed 'Best First'.
Re^4: system() returns -1 with $SIG{CHLD}?
by ikegami (Patriarch) on Feb 11, 2009 at 22:02 UTC

    Should I be doing something differently here

    Yes, you shouldn't wait for a child started with system.

    I don't want to be leaving any zombie processes around

    system doesn't leave zombies cause it waits.