rich_d_thomas has asked for the wisdom of the Perl Monks concerning the following question:
2) timeout using `<system command> ` method# add error processing as above $pid = open(KID_TO_READ, "-|"); if ($pid) { # parent while (<KID_TO_READ> ) { # do something interesting } close(KID_TO_READ) || warn "kid exited $?"; } else { # + child ($EUID, $EGID) = ($UID, $GID); # suid only exec($program, @options, @args) || die "can't exec program: $!"; # NOTREACHED } It works on Linux but on Windows I get the following error: '-' is not recognized as an internal or external command, operable pro +gram or batch file.
If the command specified by $COMMAND takes longer than the timeout specified, then the script times out successfully on Linux but on Windows, the script still waits for the command to finish.eval{ # Set the callback for the alarm signal local $SIG{ALRM} = sub { die ($TIMEOUTERROR) }; # Specify the alarm timeout alarm($TIMEOUT); my @OUTPUT=`$COMMAND 2> &1`; }; alarm(0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perlipc on Windows
by meetraz (Hermit) on Apr 19, 2004 at 21:11 UTC |