From: Raphael Hertzog Date: Sat, 16 Feb 2008 15:18:24 +0000 (+0100) Subject: Dpkg::IPC: Add chdir option X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c4ae37e4aebbaf715e31f86b046d1b36cf28d43;p=dpkg Dpkg::IPC: Add chdir option * scripts/Dpkg/IPC.pm (fork_and_exec): Add chdir option to change the current directory of the child process before calling exec. --- diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm index ee7c2c15..e4889ba6 100644 --- a/scripts/Dpkg/IPC.pm +++ b/scripts/Dpkg/IPC.pm @@ -101,6 +101,11 @@ Scalar. If containing a true value, wait_child() will be called before returning. The return value will of fork_and_exec() will be a true value, but not the pid. +=item chdir + +Scalar. The child process will chdir in the indicated directory before +calling exec. + =back =cut @@ -168,6 +173,9 @@ sub fork_and_exec { my $pid = fork(); syserr(_g("fork for %s"), "@prog") unless defined $pid; if (not $pid) { + if ($opts{"chdir"}) { + chdir($opts{"chdir"}) || syserr(_g("chdir to %s"), $opts{"chdir"}); + } # Redirect STDIN if needed if ($opts{"from_file"}) { open(STDIN, "<", $opts{"from_file"}) ||