in reply to Capture PID from child process on Windows.
The problem you are encountering is that fork creates a pseudo-process (a thread) and the "pid" returned is a (negative) threadid, not a process id.
The simplest way is to use the piped open, which spawns a real process and returns a real pid:
perl> $pid = open KID, 'perl -e"1 while sleep 1 |' or die $!;; perl> kill 21, $pid;; Terminating on signal SIGBREAK(21) perl> close KID;;
|
---|