rich_d_thomas has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

There are a number of perlipc features that I would like to use on Windows:

1) open(KID_TO_READ, "-|")

If I use the following code:
# 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.
2) timeout using `<system command> ` method

If I use the following code:
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);
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.

Please could someone let me know if this functionality is not expected to work on Windows and if there are other ways of doing this.

Thank you.

Richard Thomas

Replies are listed 'Best First'.
Re: perlipc on Windows
by meetraz (Hermit) on Apr 19, 2004 at 21:11 UTC
    For the first block of code, parent/child communication via pipes, one option is to use Win32::Pipe to do (basically) the same thing.

    For the second block of code, perl does not support alarm() functionality on Windows. You can accomplish the same thing by using the Win32::Process module to launch the external command, and then the Win32::IPC module to wait() for it to exit, with a timeout.