The following commit has been merged in the master branch:
commit 45dc465f075075f481be7c3dfac38bf041fc9c0e
Author: Guillem Jover <[email protected]>
Date:   Mon Feb 8 03:17:50 2010 +0100

    libdpkg-perl: Rename Dpkg::IPC::fork_and_exec() to Dpkg::IPC::spawn()

diff --git a/debian/changelog b/debian/changelog
index 161b079..88d7452 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -63,6 +63,7 @@ dpkg (1.15.6) UNRELEASED; urgency=low
   * Fix error handling, clean up and refactor compression code.
     Thanks to Jonathan Nieder for several of the patches.
   * Do not print unambiguous epoch on dpkg file overwrite error.
+  * Rename Dpkg::IPC::fork_and_exec() to Dpkg::IPC::spawn().
 
   [ Modestas Vainius ]
   * Implement symbol patterns (Closes: #563752). From now on, it is possible to
diff --git a/scripts/Dpkg/Compression/Process.pm 
b/scripts/Dpkg/Compression/Process.pm
index 3018a15..b7cbc03 100644
--- a/scripts/Dpkg/Compression/Process.pm
+++ b/scripts/Dpkg/Compression/Process.pm
@@ -133,7 +133,7 @@ sub _sanity_check {
 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 C<to_*> and one parameter
-C<from_*> as accepted by B<Dpkg::IPC::fork_and_exec>.
+C<from_*> as accepted by B<Dpkg::IPC::spawn>.
 
 You must call C<wait_end_process> after having called this method to
 properly close the sub-process (and verify that it exited without error).
@@ -146,7 +146,7 @@ sub compress {
     my @prog = $self->get_compress_cmdline();
     $opts{"exec"} = \...@prog;
     $self->{"cmdline"} = "@prog";
-    $self->{"pid"} = fork_and_exec(%opts);
+    $self->{"pid"} = spawn(%opts);
     delete $self->{"pid"} if $opts{"to_string"}; # wait_child already done
 }
 
@@ -155,7 +155,7 @@ sub compress {
 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 C<to_*> and one parameter
-C<from_*> as accepted by B<Dpkg::IPC::fork_and_exec>.
+C<from_*> as accepted by B<Dpkg::IPC::spawn>.
 
 You must call C<wait_end_process> after having called this method to
 properly close the sub-process (and verify that it exited without error).
@@ -168,7 +168,7 @@ sub uncompress {
     my @prog = $self->get_uncompress_cmdline();
     $opts{"exec"} = \...@prog;
     $self->{"cmdline"} = "@prog";
-    $self->{"pid"} = fork_and_exec(%opts);
+    $self->{"pid"} = spawn(%opts);
     delete $self->{"pid"} if $opts{"to_string"}; # wait_child already done
 }
 
diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm
index 8d37c70..8f74b51 100644
--- a/scripts/Dpkg/IPC.pm
+++ b/scripts/Dpkg/IPC.pm
@@ -23,7 +23,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
 
 use base qw(Exporter);
-our @EXPORT = qw(fork_and_exec wait_child);
+our @EXPORT = qw(spawn wait_child);
 
 =head1 NAME
 
@@ -40,7 +40,7 @@ from you.
 
 =over 4
 
-=item fork_and_exec
+=item spawn
 
 Creates a child process and executes another program in it.
 The arguments are interpreted as a hash of options, specifying
@@ -97,7 +97,7 @@ C<wait_child> option.
 =item wait_child
 
 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,
+returning. The return value will of spawn() will be a true value,
 but not the pid.
 
 =item nocheck
@@ -130,7 +130,7 @@ listed in the array before calling exec.
 sub _sanity_check_opts {
     my (%opts) = @_;
 
-    internerr("exec parameter is mandatory in fork_and_exec()")
+    internerr("exec parameter is mandatory in spawn()")
        unless $opts{"exec"};
 
     my $to = my $error_to = my $from = 0;
@@ -177,7 +177,7 @@ sub _sanity_check_opts {
     return %opts;
 }
 
-sub fork_and_exec {
+sub spawn {
     my (%opts) = _sanity_check_opts(@_);
     $opts{"close_in_child"} ||= [];
     my @prog;
@@ -186,7 +186,7 @@ sub fork_and_exec {
     } elsif (not ref($opts{"exec"})) {
        push @prog, $opts{"exec"};
     } else {
-       internerr("invalid exec parameter in fork_and_exec()");
+       internerr("invalid exec parameter in spawn()");
     }
     my ($from_string_pipe, $to_string_pipe, $error_to_string_pipe);
     if ($opts{"to_string"}) {
diff --git a/scripts/Dpkg/Shlibs/Cppfilt.pm b/scripts/Dpkg/Shlibs/Cppfilt.pm
index c2cfdae..80fa287 100644
--- a/scripts/Dpkg/Shlibs/Cppfilt.pm
+++ b/scripts/Dpkg/Shlibs/Cppfilt.pm
@@ -40,11 +40,11 @@ sub get_cppfilt {
     } else {
        $filt = { from => undef, to => undef,
                    last_symbol => "", last_result => "" };
-       $filt->{pid} = fork_and_exec(exec => [ 'c++filt',
-                                              '--no-verbose',
-                                              "--format=$type" ],
-                                    from_pipe => \$filt->{from},
-                                    to_pipe => \$filt->{to});
+       $filt->{pid} = spawn(exec => [ 'c++filt',
+                                      '--no-verbose',
+                                      "--format=$type" ],
+                            from_pipe => \$filt->{from},
+                            to_pipe => \$filt->{to});
        internerr(_g("unable to execute c++filt")) unless defined $filt->{from};
        $filt->{from}->autoflush(1);
 
diff --git a/scripts/Dpkg/Source/Archive.pm b/scripts/Dpkg/Source/Archive.pm
index 6739c4b..b9d021d 100644
--- a/scripts/Dpkg/Source/Archive.pm
+++ b/scripts/Dpkg/Source/Archive.pm
@@ -34,22 +34,22 @@ use base 'Dpkg::Compression::FileHandle';
 sub create {
     my ($self, %opts) = @_;
     $opts{"options"} ||= [];
-    my %fork_opts;
+    my %spawn_opts;
     # Possibly run tar from another directory
     if ($opts{"chdir"}) {
-        $fork_opts{"chdir"} = $opts{"chdir"};
+        $spawn_opts{"chdir"} = $opts{"chdir"};
         *$self->{"chdir"} = $opts{"chdir"};
     }
     # Redirect input/output appropriately
     $self->ensure_open("w");
-    $fork_opts{"to_handle"} = $self->get_filehandle();
-    $fork_opts{"from_pipe"} = \*$self->{'tar_input'};
+    $spawn_opts{"to_handle"} = $self->get_filehandle();
+    $spawn_opts{"from_pipe"} = \*$self->{'tar_input'};
     # Call tar creation process
-    $fork_opts{"delete_env"} = [ "TAR_OPTIONS" ];
-    $fork_opts{'exec'} = [ 'tar', '--null', '-T', '-', '--numeric-owner',
-                           '--owner', '0', '--group', '0',
-                          @{$opts{"options"}}, '-cf', '-' ];
-    *$self->{"pid"} = fork_and_exec(%fork_opts);
+    $spawn_opts{"delete_env"} = [ "TAR_OPTIONS" ];
+    $spawn_opts{'exec'} = [ 'tar', '--null', '-T', '-', '--numeric-owner',
+                            '--owner', '0', '--group', '0',
+                            @{$opts{"options"}}, '-cf', '-' ];
+    *$self->{"pid"} = spawn(%spawn_opts);
     *$self->{"cwd"} = getcwd();
 }
 
@@ -98,12 +98,12 @@ sub extract {
     $opts{"options"} ||= [];
     $opts{"in_place"} ||= 0;
     $opts{"no_fixperms"} ||= 0;
-    my %fork_opts = (wait_child => 1);
+    my %spawn_opts = (wait_child => 1);
 
     # Prepare destination
     my $tmp;
     if ($opts{"in_place"}) {
-        $fork_opts{"chdir"} = $dest;
+        $spawn_opts{"chdir"} = $dest;
         $tmp = $dest; # So that fixperms call works
     } else {
         my $template = basename($self->get_filename()) .  ".tmp-extract.XXXXX";
@@ -112,18 +112,18 @@ sub extract {
             mkdir($dest) || syserr(_g("cannot create directory %s"), $dest);
         }
         $tmp = tempdir($template, DIR => Cwd::realpath("$dest/.."), CLEANUP => 
1);
-        $fork_opts{"chdir"} = $tmp;
+        $spawn_opts{"chdir"} = $tmp;
     }
 
     # Prepare stuff that handles the input of tar
     $self->ensure_open("r");
-    $fork_opts{"from_handle"} = $self->get_filehandle();
+    $spawn_opts{"from_handle"} = $self->get_filehandle();
 
     # Call tar extraction process
-    $fork_opts{"delete_env"} = [ "TAR_OPTIONS" ];
-    $fork_opts{'exec'} = [ 'tar', '--no-same-owner', '--no-same-permissions',
-                           @{$opts{"options"}}, '-xkf', '-' ];
-    fork_and_exec(%fork_opts);
+    $spawn_opts{"delete_env"} = [ "TAR_OPTIONS" ];
+    $spawn_opts{'exec'} = [ 'tar', '--no-same-owner', '--no-same-permissions',
+                            @{$opts{"options"}}, '-xkf', '-' ];
+    spawn(%spawn_opts);
     $self->close();
 
     # Fix permissions on extracted files because tar insists on applying
diff --git a/scripts/Dpkg/Source/Functions.pm b/scripts/Dpkg/Source/Functions.pm
index 1be7a12..f3ed1c7 100644
--- a/scripts/Dpkg/Source/Functions.pm
+++ b/scripts/Dpkg/Source/Functions.pm
@@ -67,7 +67,7 @@ sub is_binary($) {
 
     # Use diff to check if it's a binary file
     my $diffgen;
-    my $diff_pid = fork_and_exec(
+    my $diff_pid = spawn(
         'exec' => [ 'diff', '-u', '--', '/dev/null', $file ],
         'env' => { LC_ALL => 'C', LANG => 'C', TZ => 'UTC0' },
         'to_pipe' => \$diffgen
diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm
index 4d8351d..61f00a9 100644
--- a/scripts/Dpkg/Source/Package.pm
+++ b/scripts/Dpkg/Source/Package.pm
@@ -282,9 +282,9 @@ sub check_signature {
         push @exec, $dsc;
 
         my ($stdout, $stderr);
-        fork_and_exec('exec' => \...@exec, wait_child => 1, nocheck => 1,
-                      to_string => \$stdout, error_to_string => \$stderr,
-                      timeout => 10);
+        spawn('exec' => \...@exec, wait_child => 1, nocheck => 1,
+              to_string => \$stdout, error_to_string => \$stderr,
+              timeout => 10);
         if (WIFEXITED($?)) {
             my $gpg_status = WEXITSTATUS($?);
             print STDERR "$stdout$stderr" if $gpg_status;
diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm
index 5c465d8..3d9f5d9 100644
--- a/scripts/Dpkg/Source/Patch.pm
+++ b/scripts/Dpkg/Source/Patch.pm
@@ -96,7 +96,7 @@ sub add_diff_file {
     }
     # Generate diff
     my $diffgen;
-    my $diff_pid = fork_and_exec(
+    my $diff_pid = spawn(
         'exec' => [ 'diff', '-u', @options, '--', $old, $new ],
         'env' => { LC_ALL => 'C', LANG => 'C', TZ => 'UTC0' },
         'to_pipe' => \$diffgen
@@ -437,7 +437,7 @@ sub apply {
     $self->prepare_apply($analysis, %opts);
     # Apply the patch
     $self->ensure_open("r");
-    fork_and_exec(
+    spawn(
        'exec' => [ 'patch', @{$opts{"options"}} ],
        'chdir' => $destdir,
        'env' => { LC_ALL => 'C', LANG => 'C' },
@@ -477,7 +477,7 @@ sub check_apply {
     # Apply the patch
     $self->ensure_open("r");
     my $error;
-    my $patch_pid = fork_and_exec(
+    my $patch_pid = spawn(
        'exec' => [ 'patch', @{$opts{"options"}} ],
        'chdir' => $destdir,
        'env' => { LC_ALL => 'C', LANG => 'C' },
diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl
index e369cec..9318864 100755
--- a/scripts/dpkg-scanpackages.pl
+++ b/scripts/dpkg-scanpackages.pl
@@ -186,8 +186,8 @@ FILE:
        chomp;
        my $fn = $_;
        my $output;
-       my $pid = fork_and_exec('exec' => [ "dpkg-deb", "-I", $fn, "control" ],
-                               'to_pipe' => \$output);
+       my $pid = spawn('exec' => [ "dpkg-deb", "-I", $fn, "control" ],
+                       'to_pipe' => \$output);
        my $fields = Dpkg::Control->new(type => CTRL_INDEX_PKG);
        $fields->parse_fh($output, $fn)
            or error(_g("couldn't parse control information from %s."), $fn);
diff --git a/scripts/t/800_Dpkg_IPC.t b/scripts/t/800_Dpkg_IPC.t
index 0390b3a..706c0ff 100644
--- a/scripts/t/800_Dpkg_IPC.t
+++ b/scripts/t/800_Dpkg_IPC.t
@@ -33,17 +33,17 @@ open TMP, '>', $tmp_name;
 print TMP $string;
 close TMP;
 
-my $pid = fork_and_exec(exec => "cat",
-                       from_string => \$string,
-                       to_string => \$string2);
+my $pid = spawn(exec => "cat",
+               from_string => \$string,
+               to_string => \$string2);
 
 ok($pid);
 
 is($string2, $string, "{from,to}_string");
 
-$pid = fork_and_exec(exec => "cat",
-                    from_handle => $tmp_fh,
-                    to_handle => $tmp2_fh);
+$pid = spawn(exec => "cat",
+            from_handle => $tmp_fh,
+            to_handle => $tmp2_fh);
 
 ok($pid);
 
@@ -55,11 +55,11 @@ close TMP;
 
 is($string2, $string, "{from,to}_handle");
 
-$pid = fork_and_exec(exec => "cat",
-                    from_file => $tmp_name,
-                    to_file => $tmp2_name,
-                    wait_child => 1,
-                    timeout => 5);
+$pid = spawn(exec => "cat",
+            from_file => $tmp_name,
+            to_file => $tmp2_name,
+            wait_child => 1,
+            timeout => 5);
 
 ok($pid);
 
@@ -70,9 +70,9 @@ close TMP;
 is($string2, $string, "{from,to}_file");
 
 eval {
-    $pid = fork_and_exec(exec => ["sleep", "10"],
-                        wait_child => 1,
-                        timeout => 5);
+    $pid = spawn(exec => ["sleep", "10"],
+                wait_child => 1,
+                timeout => 5);
 };
 ok($@, "fails on timeout");
 
diff --git a/scripts/t/900_update_alternatives.t 
b/scripts/t/900_update_alternatives.t
index d630ddf..691ad8e 100644
--- a/scripts/t/900_update_alternatives.t
+++ b/scripts/t/900_update_alternatives.t
@@ -76,8 +76,8 @@ sub cleanup {
 
 sub call_ua {
     my ($params, %opts) = @_;
-    fork_and_exec("exec" => [ @ua, @$params ], nocheck => 1,
-                 wait_child => 1, env => { LC_ALL => "C" }, %opts);
+    spawn("exec" => [ @ua, @$params ], nocheck => 1,
+         wait_child => 1, env => { LC_ALL => "C" }, %opts);
     if ($opts{"expect_failure"}) {
        ok($? != 0, "update-alternatives @$params did not fail.");
     } else {

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to