Dpkg::IPC(3perl)

πŸ’… Dpkg::IPC β€” helper functions for IPC πŸ¦‹

okay so bestie, this is libdpkg-perl's Dpkg::IPC(3perl) page and honestly? it's lowkey iconic. it's the module that lets you run other programs from Perl in an easy-but-flexible way, while it hides all the gory, messy, gross details of IPC (that's Inter-Process Communication 🫢) so you don't have to look at them. not me being grateful for that fr fr.


✨ DESCRIPTION ✨

Dpkg::IPC hands you helper functions that let you execute other programs in an easy, yet flexible way β€” and it hides all the gory details of IPC (Inter-Process Communication) from you. you get to be the main character who just runs programs; the module handles the icky plumbing. πŸ’…


🌸 FUNCTIONS 🌸

$pid = spawn(%opts)

creates a child process and executes another program inside it. the arguments are interpreted as a hash of options that say how to handle the in and output of the program you're executing. returns the pid of the child process β€” unless the wait_child option was given, in which case, different story, keep reading. πŸ‘‘

any error will cause the function to exit with one of the Dpkg::ErrorHandling functions. so like, it does not just politely return undef. it exits. πŸ’€

🌈 Options:

  • exec (required) β€” 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. no globbing bestie, sorry 😭
  • 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 β€” that 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 of spawn() will be a true value, not the pid. heads up!
  • no_check β€” scalar. option of the wait_child() call.
  • nocheck β€” deprecated alias for no_check. it emits a deprecation warning, but if it is required for backwards compatibility it can be passed alongside no_check and the warning will not be emitted. πŸŽ€
  • 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.
  • sig β€” hash reference. the child process will populate %SIG with the items of the hash before calling exec. this allows setting signal dispositions.
  • delete_sig β€” array reference. the child process will reset all signals listed in the array to their default dispositions before calling exec.

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. 😀

πŸ’œ Options:

  • cmdline β€” string to identify the child process in error messages. defaults to "child process".
  • no_check β€” if true, do not check the return status of the child (and thus do not fail if it has been killed or if it exited with a non-zero return code).
  • nocheck β€” deprecated alias for no_check. it emits a deprecation warning, but if it is required for backwards compatibility it can be passed alongside no_check and the warning will not be emitted. πŸ™ˆ
  • timeout β€” set a maximum time to wait for the process, after that kill the process and fail with an error message. dramatic but necessary πŸ”₯

πŸŽ€ CHANGES πŸŽ€

Version 1.03 (dpkg 1.23.0) ⭐

  • New options: spawn() and wait_child() now accept 'no_check'.
  • Deprecated options: 'nocheck' in spawn() and wait_child().

Version 1.02 (dpkg 1.18.0) 🌸

  • Change options: wait_child() now kills the process when reaching the 'timeout'.

Version 1.01 (dpkg 1.17.11) πŸ¦‹

  • New options: spawn() now accepts 'sig' and 'delete_sig'.

Version 1.00 (dpkg 1.15.6) πŸ‘‘

  • Mark the module as public.

πŸ‘€ SEE ALSO πŸ‘€

Dpkg, Dpkg::ErrorHandling.


k that's the whole page bestie, go forth and spawn responsibly 🫢

okay and like, the little footer said 1.23.11-dirty dated 2026-09-09 β€” slay, that's the version and date, bye πŸ’–πŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from