Dpkg::Compression::Process(3) libdpkg-perl Dpkg::Compression::Process(3)NAME
Dpkg::Compression::Process - run compression/decompression processes
DESCRIPTION
This module provides an object oriented interface to run and manage compression/decompression processes.
METHODS
my $proc = Dpkg::Compression::Process->new(%opts)
Create a new instance of the object. Supported options are "compression" and "compression_level" (see corresponding set_* functions).
$proc->set_compression($comp)
Select the compression method to use. It errors out if the method is not supported according to "compression_is_supported" (of
Dpkg::Compression).
$proc->set_compression_level($level)
Select the compression level to use. It errors out if the level is not valid according to "compression_is_valid_level" (of
Dpkg::Compression).
my @exec = $proc->get_compress_cmdline()
my @exec = $proc->get_uncompress_cmdline()
Returns a list ready to be passed to "exec", its first element is the program name (either for compression or decompression) and the
following elements are parameters for the program.
When executed the program acts as a filter between its standard input and its standard output.
$proc->compress(%opts)
Starts a compressor program. You must indicate where it will read its uncompressed data from and where it will write its compressed
data to. This is accomplished by passing one parameter "to_*" and one parameter "from_*" as accepted by Dpkg::IPC::spawn.
You must call "wait_end_process" after having called this method to properly close the sub-process (and verify that it exited without
error).
$proc->uncompress(%opts)
Starts a decompressor program. You must indicate where it will read its compressed data from and where it will write its uncompressed
data to. This is accomplished by passing one parameter "to_*" and one parameter "from_*" as accepted by Dpkg::IPC::spawn.
You must call "wait_end_process" after having called this method to properly close the sub-process (and verify that it exited without
error).
$proc->wait_end_process(%opts)
Call Dpkg::IPC::wait_child to wait until the sub-process has exited and verify its return code. Any given option will be forwarded to
the "wait_child" function. Most notably you can use the "nocheck" option to verify the return code yourself instead of letting
"wait_child" do it for you.
AUTHOR
Raphael Hertzog <hertzog@debian.org>.
1.16.0.3 2012-04-17 Dpkg::Compression::Process(3)
Check Out this Related Man Page
Dpkg::IPC(3) libdpkg-perl Dpkg::IPC(3)NAME
Dpkg::IPC - helper functions for IPC
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.
METHODS
spawn
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).
Any error will cause the function to exit with one of the Dpkg::ErrorHandling functions.
Options:
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.
Mandatory Option.
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.
from_handle, to_handle, error_to_handle
Filehandle. Standard input/output/error of the child process will be dup'ed from the handle.
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 ("to_pipe"
and "error_to_pipe") or the writing end ("from_pipe") 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.
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 "from_string", as the string is not modified in any way. This was
chosen only for reasons of symmetry with "to_string" and "error_to_string". "to_string" and "error_to_string" imply the
"wait_child" option.
wait_child
Scalar. If containing a true value, wait_child() will be called before returning. The return value will of spawn() will be a true
value, but not the pid.
nocheck
Scalar. Option of the wait_child() call.
timeout
Scalar. Option of the wait_child() call.
chdir
Scalar. The child process will chdir in the indicated directory before calling exec.
env Hash reference. The child process will populate %ENV with the items of the hash before calling exec. This allows exporting
environment variables.
delete_env
Array reference. The child process will remove all environment variables listed in the array before calling exec.
wait_child
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.
Options:
cmdline
String to identify the child process in error messages. Defaults to "child process".
nocheck
If true do not check the return status of the child (and thus do not fail it it has been killed or if it exited with a non-zero
return code).
timeout
Set a maximum time to wait for the process, after that fail with an error message.
AUTHORS
Written by Raphael Hertzog <hertzog@debian.org> and Frank Lichtenheld <djpig@debian.org>.
SEE ALSO
Dpkg, Dpkg::ErrorHandling
1.16.15 2014-06-05 Dpkg::IPC(3)