in reply to Re: Killing a system/exec/`` call if it times out
in thread Killing a system/exec/`` call if it times out

Thanks, it's a simple call to a program which will hopefully create an image for me, just a program and 2 parameters, no redirection.

Although it is doing the "sh -c ..." approach as you mentioned. I don't care how it's called either, system(), exec(), or backticks.

I could collect the PIDs based on their parent, but would love a one-liner-ish. :)
  • Comment on Re^2: Killing a system/exec/`` call if it times out

Replies are listed 'Best First'.
Re^3: Killing a system/exec/`` call if it times out
by ww (Archbishop) on Dec 01, 2011 at 20:24 UTC
    "I don't care how it's called either, system(), exec(), or backticks."
    Actually, yes you do (or should): see the docs for exec, taking special notes of the first paragraph:
    "The "exec" function executes a system command *and never returns*; use "system" instead of "exec" if you want it to return. It fails and returns false only if the command does not exist *and* it is executed directly instead of via your system's command shell (see below)."

    And the difference between system and backticks? sgifford put it clearly and succinctly ( in Re: system() vs `backtick`, q.v. ) back in 2004, when he said "backticks send the executed program's STDOUT to a variable, and system sends it to your main program's STDOUT."

    But, don't quit there; read similarly re system. And re backticks... well you get the idea.

      hehe, true, and I already did.

      I meant which gives me the easiest solution is fine by me. :)