in reply to Re: Killing of ALL children made by Open3
in thread Killing of ALL children made by Open3

Hello sgifford,

I modified your code to fit my example by changing one of the my_open3's to:

my_open3(\*STDOUT,\*STDIN,\*STDOUT,"ping -t localhost");

I was excited that your code seemed to work off the bat (no more lingering PINGS), unfortunately, it appears that the pings are not even being created, because the CMD.exe spawned by Open3 is being killed before it can spawn the PING (I believe, not sure though).

I tested this by throwing in a sleep(10); before the my_killkids('INT'); and sure enough PING is created and stays around after all the killing is finished.

I appreciate the reply, I will continue to work with your code because I believe you are on the right track.

Thanks,
Steve

Replies are listed 'Best First'.
Re: Re: Re: Killing of ALL children made by Open3
by sgifford (Prior) on Nov 12, 2003 at 21:03 UTC

    I don't have any Windows machines to test on; it works on Linux.

    One thing I noticed is that my arguments to open3 were wrong. This works better:

    my_open3(\*STDIN,'>&STDOUT','>&STDOUT',"ping 10.0.0.1"); my_open3(\*STDIN,'>&STDOUT','>&STDOUT',"ping 10.0.0.100"); my_open3(\*STDIN,'>&STDOUT','>&STDOUT',"ping 10.0.0.2");

    Another thing to think about is that CMD.EXE and PING could both be running at the same time, so killing the PID returned by open3 might just kill CMD.EXE and leave PING alone. You might be able to avoid running CMD.EXE by giving open3 ping and its arguments as a list instead of a string:

    my_open3(\*STDIN,'>&STDOUT','>&STDOUT','ping', '10.0.0.2');
    but I'm not sure.
      Hello,

      Well, I have done some quick testing and it appears that seperating out the args, as you suggested, works just fine.

      I will report back if I find anything out of interest, but overall, thank you for your time and effort, it is greatly appreciated.

      Steve