NAME
IOMux::IPC - exchange data with external command
INHERITANCE
IOMux::IPC
is an IOMux::Bundle
is an IOMux::Handler::Read
is an IOMux::Handler
IOMux::Bundle also extends IOMux::Handler::Write
is an IOMux::Handler::Write
is an IOMux::Handler
SYNOPSIS
my $mux = IOMux::Select->new; # or ::Poll
use IOMux::Open '|-|', '|=|';
my $pipe = $mux->open('|-|', $cmd, @cmdopts);
use IOMux::IPC;
my $ipc = IOMux::IPC->new(command => [$cmd, @cmdopts]);
$mux->add($ipc);
$pipe->getline(sub {print "$_[0]\n"});
DESCRIPTION
With this handler, you set-up a two way communication between the current process and some other process. This is not easy to program: you may need to play with timeouts every once in a while.
This module is based on IOMux::Bundle, because it will use two or three pipes to facilitate the communication.
Extends "DESCRIPTION" in IOMux::Bundle.
METHODS
Extends "METHODS" in IOMux::Bundle.
Constructors
Extends "Constructors" in IOMux::Bundle.
- IOMux::IPC->new(%options)
-
-Option --Defined in --Default command <required> errors <true> fh IOMux::Handler <required> mode |=| name IOMux::Handler '|$cmd|' read_size IOMux::Handler::Read 32768 stderr IOMux::Bundle <undef> stdin IOMux::Bundle <required> stdout IOMux::Bundle <required> write_size IOMux::Handler::Write 4096
- command => COMMAND|ARRAY
-
The external command to be executed. Either the COMMAND needs to parameters, or you need to pass an ARRAY of the command name and all its parameters.
- errors => BOOLEAN
-
Include the stderr channel in the communication as well. These will be printed to STDERR by default.
- fh => FILEHANDLE
- mode =>
|-|
or|=|
-
In the
|-|
mode, only STDIN and STDOUT are processed. Specifing the|=|
has the same effect as setting theerrors
option: open a connection for STDERR as well. - name => STRING
- read_size => INTEGER
- stderr => IOMux::Handler::Read object
- stdin => IOMux::Handler::Write object
- stdout => IOMux::Handler::Read object
- write_size => INTEGER
- IOMux::IPC->open( $mode, <$cmd, $cmdopts>|<$cmdarray, %options> )
-
Open the pipe to read. $mode is either
|-|
or|=|
. When you need to pass additional %options to the implied new(), then you must use an ARRAY for command name and its optional parameters.example:
my $mux = IOMux::Poll->new; $mux->open('|-|', 'sort', '-u'); # no opts $mux->open('|-|', ['sort', '-u'], %opts); $mux->open('|-|', 'sort'); # no opts $mux->open('|-|', ['sort'], %opts);
Accessors
Extends "Accessors" in IOMux::Bundle.
- $obj->childPid()
-
The process id of the child on the other side of the pipe.
- $obj->connections()
-
Inherited, see "Accessors" in IOMux::Bundle
- $obj->fh()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->fh()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->fileno()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->fileno()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->mode()
-
The bits of the open mode.
- $obj->mux()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->mux()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->name()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->name()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->readSize( [$integer] )
-
Inherited, see "Accessors" in IOMux::Handler::Read
- $obj->stderr()
-
Inherited, see "Accessors" in IOMux::Bundle
- $obj->stdin()
-
Inherited, see "Accessors" in IOMux::Bundle
- $obj->stdout()
-
Inherited, see "Accessors" in IOMux::Bundle
- $obj->usesSSL()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->usesSSL()
-
Inherited, see "Accessors" in IOMux::Handler
- $obj->writeSize( [$integer] )
-
Inherited, see "Accessors" in IOMux::Handler::Write
User interface
Extends "User interface" in IOMux::Bundle.
Multiplexer
Extends "Multiplexer" in IOMux::Bundle.
Helpers
Extends "Helpers" in IOMux::Bundle.
- $obj->extractSocket(HASH)
- IOMux::IPC->extractSocket(HASH)
-
Inherited, see "Helpers" in IOMux::Handler
- $obj->extractSocket(HASH)
- IOMux::IPC->extractSocket(HASH)
-
Inherited, see "Helpers" in IOMux::Handler
- $obj->fdset($state, $read, $write, $error)
-
Inherited, see "Helpers" in IOMux::Handler
- $obj->fdset($state, $read, $write, $error)
-
Inherited, see "Helpers" in IOMux::Handler
- $obj->show()
-
Inherited, see "Helpers" in IOMux::Handler
- $obj->show()
-
Inherited, see "Helpers" in IOMux::Handler
SEE ALSO
This module is part of IOMux distribution version 1.01, built on January 15, 2020. Website: http://perl.overmeer.net/CPAN
LICENSE
Copyrights 2011-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/