summaryrefslogtreecommitdiff
path: root/scripts/Dpkg/IPC.pm
diff options
context:
space:
mode:
authorRaphael Hertzog <hertzog@debian.org>2008-02-16 16:18:24 +0100
committerRaphael Hertzog <hertzog@debian.org>2008-02-16 16:18:24 +0100
commit1c4ae37e4aebbaf715e31f86b046d1b36cf28d43 (patch)
tree62b7ba1a810389bab597b2d3dfca1194fc834384 /scripts/Dpkg/IPC.pm
parent8809ecced7e0972959891426fb2a9fbf893d3a74 (diff)
downloaddpkg-1c4ae37e4aebbaf715e31f86b046d1b36cf28d43.tar.gz
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.
Diffstat (limited to 'scripts/Dpkg/IPC.pm')
-rw-r--r--scripts/Dpkg/IPC.pm8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm
index ee7c2c15a..e4889ba64 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"}) ||