Selaa lähdekoodia

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.
Raphael Hertzog 18 vuotta sitten
vanhempi
commit
1c4ae37e4a
1 muutettua tiedostoa jossa 8 lisäystä ja 0 poistoa
  1. 8 0
      scripts/Dpkg/IPC.pm

+ 8 - 0
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"}) ||