.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Dpkg::IPC 3perl" .TH Dpkg::IPC 3perl 2024-03-10 1.22.6 libdpkg-perl .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Dpkg::IPC \- helper functions for IPC .SH DESCRIPTION .IX Header "DESCRIPTION" Dpkg::IPC offers helper functions to allow you to execute other programs in an easy, yet flexible way, while hiding all the gory details of IPC (Inter-Process Communication) from you. .SH FUNCTIONS .IX Header "FUNCTIONS" .ie n .IP "$pid = spawn(%opts)" 4 .el .IP "\f(CW$pid\fR = spawn(%opts)" 4 .IX Item "$pid = spawn(%opts)" Creates a child process and executes another program in it. The arguments are interpreted as a hash of options, specifying how to handle the in and output of the program to execute. Returns the pid of the child process (unless the wait_child option was given). .Sp Any error will cause the function to exit with one of the Dpkg::ErrorHandling functions. .Sp Options: .RS 4 .IP exec 4 .IX Item "exec" Can be either a scalar, i.e. the name of the program to be executed, or an array reference, i.e. the name of the program plus additional arguments. Note that the program will never be executed via the shell, so you can't specify additional arguments in the scalar string and you can't use any shell facilities like globbing. .Sp Mandatory Option. .IP "from_file, to_file, error_to_file" 4 .IX Item "from_file, to_file, error_to_file" Filename as scalar. Standard input/output/error of the child process will be redirected to the file specified. .IP "from_handle, to_handle, error_to_handle" 4 .IX Item "from_handle, to_handle, error_to_handle" Filehandle. Standard input/output/error of the child process will be dup'ed from the handle. .IP "from_pipe, to_pipe, error_to_pipe" 4 .IX Item "from_pipe, to_pipe, error_to_pipe" Scalar reference or object based on IO::Handle. A pipe will be opened for each of the two options and either the reading (\f(CW\*(C`to_pipe\*(C'\fR and \&\f(CW\*(C`error_to_pipe\*(C'\fR) or the writing end (\f(CW\*(C`from_pipe\*(C'\fR) will be returned in the referenced scalar. Standard input/output/error of the child process will be dup'ed to the other ends of the pipes. .IP "from_string, to_string, error_to_string" 4 .IX Item "from_string, to_string, error_to_string" Scalar reference. Standard input/output/error of the child process will be redirected to the string given as reference. Note that it wouldn't be strictly necessary to use a scalar reference for \f(CW\*(C`from_string\*(C'\fR, as the string is not modified in any way. This was chosen only for reasons of symmetry with \f(CW\*(C`to_string\*(C'\fR and \&\f(CW\*(C`error_to_string\*(C'\fR. \f(CW\*(C`to_string\*(C'\fR and \f(CW\*(C`error_to_string\*(C'\fR imply the \&\f(CW\*(C`wait_child\*(C'\fR option. .IP wait_child 4 .IX Item "wait_child" Scalar. If containing a true value, \fBwait_child()\fR will be called before returning. The return value of \fBspawn()\fR will be a true value, not the pid. .IP nocheck 4 .IX Item "nocheck" Scalar. Option of the \fBwait_child()\fR call. .IP timeout 4 .IX Item "timeout" Scalar. Option of the \fBwait_child()\fR call. .IP chdir 4 .IX Item "chdir" Scalar. The child process will chdir in the indicated directory before calling exec. .IP env 4 .IX Item "env" Hash reference. The child process will populate \f(CW%ENV\fR with the items of the hash before calling exec. This allows exporting environment variables. .IP delete_env 4 .IX Item "delete_env" Array reference. The child process will remove all environment variables listed in the array before calling exec. .IP sig 4 .IX Item "sig" Hash reference. The child process will populate \f(CW%SIG\fR with the items of the hash before calling exec. This allows setting signal dispositions. .IP delete_sig 4 .IX Item "delete_sig" Array reference. The child process will reset all signals listed in the array to their default dispositions before calling exec. .RE .RS 4 .RE .ie n .IP "wait_child($pid, %opts)" 4 .el .IP "wait_child($pid, \f(CW%opts\fR)" 4 .IX Item "wait_child($pid, %opts)" Takes as first argument the pid of the process to wait for. Remaining arguments are taken as a hash of options. Returns nothing. Fails if the child has been ended by a signal or if it exited non-zero. .Sp Options: .RS 4 .IP cmdline 4 .IX Item "cmdline" String to identify the child process in error messages. Defaults to "child process". .IP nocheck 4 .IX Item "nocheck" If true do not check the return status of the child (and thus do not fail it has been killed or if it exited with a non-zero return code). .IP timeout 4 .IX Item "timeout" Set a maximum time to wait for the process, after that kill the process and fail with an error message. .RE .RS 4 .RE .SH CHANGES .IX Header "CHANGES" .SS "Version 1.02 (dpkg 1.18.0)" .IX Subsection "Version 1.02 (dpkg 1.18.0)" Change options: \fBwait_child()\fR now kills the process when reaching the 'timeout'. .SS "Version 1.01 (dpkg 1.17.11)" .IX Subsection "Version 1.01 (dpkg 1.17.11)" New options: \fBspawn()\fR now accepts 'sig' and 'delete_sig'. .SS "Version 1.00 (dpkg 1.15.6)" .IX Subsection "Version 1.00 (dpkg 1.15.6)" Mark the module as public. .SH "SEE ALSO" .IX Header "SEE ALSO" Dpkg, Dpkg::ErrorHandling.