MAN page from Old RedHat 5.X perl-5.004-4.i386.rpm
IPC::Open3
Section: Perl Programmers Reference Guide (3)
Updated: perl 5.004, patch 04
Index NAME
IPC::Open3, open3 - open a process for reading, writing, and error handling
SYNOPSIS
$pid = open3(\*WTRFH, \*RDRFH, \*ERRFH, 'some cmd and args', 'optarg', ...);
DESCRIPTION
Extremely similar to
open2(),
open3() spawns the given
$cmd andconnects RDRFH for reading, WTRFH for writing, and ERRFH for errors. IfERRFH is `', or the same as RDRFH, then STDOUT and STDERR of the child areon the same file handle. The WTRFH will have autoflush turned on.
If WTRFH begins with ``<&'', then WTRFH will be closed in the parent, andthe child will read from it directly. If RDRFH or ERRFH begins with``>&'', then the child will send output directly to that file handle.In both cases, there will be a dup(2) instead of a pipe(2) made.
If you try to read from the child's stdout writer and their stderrwriter, you'll have problems with blocking, which means you'llwant to use select(), which means you'll have to use sysread() insteadof normal stuff.
open3() returns the process ID of the child process. It doesn't return onfailure: it just raises an exception matching /^open3:/.
WARNING
It will not create these file handles for you. You have to do thisyourself. So don't pass it empty variables expecting them to get filledin for you.
Additionally, this is very dangerous as you may block forever. Itassumes it's going to talk to something like bc, both writing to itand reading from it. This is presumably safe because you ``know'' thatcommands like bc will read a line at a time and output a line at atime. Programs like sort that read their entire input stream first,however, are quite apt to cause deadlock.
The big problem with this approach is that if you don't have controlover source code being run in the child process, you can't controlwhat it does with pipe buffering. Thus you can't just open a pipe tocat -v and continually read and write a line from it.
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- WARNING
This document was created byman2html,using the manual pages.