|command => ARRAY or STRING||Either a reference to an array containing the command and its arguments, or a plain string containing the command. This value is passed into perls exec function.|
|code => CODE||A block of code to execute in the child process. It will be called in scalar context inside an eval block.|
|setup => ARRAY||A reference to an array which gives file descriptors to set up in the child process before running the code or command. See below.|
|on_exit => CODE||
A continuation to be called when the child processes exits. It will be invoked
in the following way:
The second argument is passed the plain perl $? value.
If the command key is used, the given array or string is executed using the exec function.
Case | ($exitcode >> 8) | $dollarbang | $dollarat
exec succeeds | exit code from program | 0 | ""
exec fails | 255 | $! | ""
$code returns | return value | $! | ""
$code dies | 255 | $! | $@
It is usually more convenient to use the open_child method in simple cases
where an external program is being started in order to interact with it via
file IO, or even run_child when only the final result is required, rather
than interaction while it is running.
This array gives a list of file descriptor operations to perform in the child
process after it has been fork(2)ed from the parent, before running the code
or command. It consists of name/value pairs which are ordered; the operations
are performed in the order given.
|fdn => ARRAY||
Gives an operation on file descriptor n. The first element of the array
defines the operation to be performed:
A non-reference value may be passed as a shortcut, where it would contain the name of the operation with no arguments (i.e. for the close and keep operations).
|IO => ARRAY||
Shortcut for passing fdn, where n is the fileno of the IO
reference. In this case, the key must be a reference that implements the
fileno method. This is mostly useful for
|fdn => IO||A shortcut for the dup case given above.|
|stdin => ...|
|stdout => ...|
|stderr => ...||Shortcuts for fd0, fd1 and fd2 respectively.|
|env => HASH||
A reference to a hash to set as the child processs environment.
Note that this will entirely set a new environment, completely replacing the existing one. If you want to simply add new keys or change the values of some keys without removing the other existing ones, you can simply copy %ENV into the hash before setting new keys:
|nice => INT||Change the child processs scheduling priority using POSIX::nice.|
|chdir => STRING||Change the child processs working directory using chdir.|
|setuid => INT|
|setgid => INT||Change the child processs effective UID or GID.|
|setgroups => ARRAY||
Change the child processs groups list, to those groups whose numbers are
given in the ARRAY reference.
If setting both the primary GID and the supplementary groups list, it is suggested to set the primary GID first. Moreover, some operating systems may require that the supplementary groups list contains the primary GID.
If setuid is used, be sure to place it after any other operations that might require superuser privileges, such as setgid or opening special files.
Paul Evans <email@example.com>
|perl v5.20.3||IO::ASYNC::CHILDMANAGER (3)||2015-12-15|