in reply to Re^2: Terminating a parallel process opened with "system(..)"
in thread Terminating a parallel process opened with "system(..)"

See how you get on with this version?

#! perl -slw use strict; my $filename = $ARGV[0]; my( $ext ) = $filename =~ m[(\.[^.]+)$]; my( $assoc ) = `assoc $ext` =~ m[=(.+)$]; my( $ftype ) = `ftype $assoc` =~ m[=(.+)$]; $ftype =~ s[%(\w+)%][ $ENV{ $1 } ]ge; $ftype =~ s[^("[^"]+?"|\S+)\K.+$][]; #" print $ftype, ':', $filename; my $pid = system 1, $ftype, $filename; print $pid; sleep 10; kill 9, $pid;

Note: This isn't intended to be a complete replacement for the start command, just a starting point for you to adapt to your needs.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^4: Terminating a parallel process opened with "system(..)"
by palkia (Monk) on Jun 03, 2012 at 22:05 UTC
    Thank you very much, it works gr8.

    One followup question if you don't mind:
    Should I be worried about zombie process resulting from this "kill" ? (I really can't pull off the bite marks look)
    Would substituting the kill 9, $pid; for while(kill 9, $pid){} or while(kill 9, $pid){sleep 1;}
    would prevent zombies / decrease the chance for zombies / none of the above ?
    Other / better techniques ?
    Thx

      Windows doesn't do zombie processes.

      However, perl attempts to emulate the ability to retrieve the exit code from child processes by storing them within the parent, from where they can be retrieved using wait and $? or waitpid.

      A side effect of this is that you can only start 64 child processes before you must free up slots in a perl internal structure by calling one of wait or waitpid. If you are starting less than 64 processes, you can happily and economically ignore this caveat.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?