in reply to Killing subprocess in windows

system does not return the PID when used in your way, but you can simulate start by using system(1, ...):

my $pid = system(1, "cmd /c powershell gc -tail 10 -wait $logfile" );

That way, you can kill it. See perlport on the form system(1, ...).

Replies are listed 'Best First'.
Re^2: Killing subprocess in windows
by LanX (Saint) on May 20, 2021 at 21:14 UTC
    Hi

    > but you can simulate start by using system(1, ...):

    hm ... not really, start was also necessary to launch a new window in parallel

    > See perlport on the form system(1, ...).

    yeah I missed that, great.

    > That way, you can kill it.

    yes it works, but with a negative signal like with kill("-KILL",$pid)

    That's because I have to target the child process(es) of start/cmd ...

    Thanks :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery