NAME

IPC::Run::Win32Helper - helper routines for IPC::Run on Win32 platforms.

SYNOPSIS

use IPC::Run::Win32Helper ; # Exports all by default

DESCRIPTION

IPC::Run needs to use sockets to redirect subprocess I/O so that the select() loop will work on Win32. This seems to only work on WinNT and Win2K at this time, not sure if it will ever work on Win95 or Win98. If you have experience in this area, please contact me at barries@slaysys.com, thanks!.

FUNCTIONS

win32_fake_pipe
$fake_pipe = win32_fake_pipe ;

Just a safe wrapper around listen(). Chooses a port number >= 2048 to listen on. Call $fake_pipe->parent_handle() after spawning the children to do the accept() and get a valid "pipe" handle.

We need to build an IPC::Run::Pipe class and make a IPC::Run::Pipe::Win32tcp subclass of it, I think.

win32_parse_cmd_line
@words = win32_parse_cmd_line( q{foo bar 'baz baz' "bat bat"} ) ;

returns 4 words. This parses like the bourne shell (see the bit about shellwords() in Text::ParseWords), assuming we're trying to be a little cross-platform here. The only difference is that "\" is *not* treated as an escape except when it precedes punctuation, since it's used all over the place in DOS path specs.

TODO: globbing? probably not (it's unDOSish).

TODO: shebang emulation? Probably, but perhaps that should be part of Run.pm so all spawned processes get the benefit.

LIMITATIONS: shellwords dies silently on malformed input like

a\"
win32_spawn

Spawns a child process, possibly with STDIN, STDOUT, and STDERR (file descriptors 0, 1, and 2, respectively) redirected.

LIMITATIONS.

Cannot redirect higher file descriptors due to lack of support for this in the Win32 environment.

This can be worked around by marking a handle as inheritable in the parent (or leaving it marked; this is the default in perl), obtaining it's Win32 handle with Win32API::GetOSFHandle(FH) or Win32API::FdGetOsFHandle($fd) and passing it to the child using the command line, the environment, or any other IPC mechanism (it's a plain old integer). The child can then use OsFHandleOpen() or OsFHandleOpenFd() and possibly <open FOO "&BAR">> or <open FOO "&$fd>> as need be. Ach, the pain!

Remember to check the Win32 handle against INVALID_HANDLE_VALUE.

AUTHOR

Barries Slaymaker <barries@slaysys.com>. Funded by Perforce Software, Inc.

COPYRIGHT

Copyright 2001, Barrie Slaymaker, All Rights Reserved.

You may use this under the terms of either the GPL 2.0 ir the Artistic License.