diff options
author | Guillem Jover <guillem@debian.org> | 2010-02-08 03:17:50 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2010-02-19 06:48:26 +0100 |
commit | 45dc465f075075f481be7c3dfac38bf041fc9c0e (patch) | |
tree | 9a2411f1501b098cb889396de5a2e018089a9a70 /scripts | |
parent | bf4c40bc0cebcf937854aa259c6729da9c975768 (diff) | |
download | dpkg-45dc465f075075f481be7c3dfac38bf041fc9c0e.tar.gz |
libdpkg-perl: Rename Dpkg::IPC::fork_and_exec() to Dpkg::IPC::spawn()
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Dpkg/Compression/Process.pm | 8 | ||||
-rw-r--r-- | scripts/Dpkg/IPC.pm | 12 | ||||
-rw-r--r-- | scripts/Dpkg/Shlibs/Cppfilt.pm | 10 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Archive.pm | 34 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Functions.pm | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package.pm | 6 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Patch.pm | 6 | ||||
-rwxr-xr-x | scripts/dpkg-scanpackages.pl | 4 | ||||
-rw-r--r-- | scripts/t/800_Dpkg_IPC.t | 28 | ||||
-rw-r--r-- | scripts/t/900_update_alternatives.t | 4 |
10 files changed, 57 insertions, 57 deletions
diff --git a/scripts/Dpkg/Compression/Process.pm b/scripts/Dpkg/Compression/Process.pm index 3018a1526..b7cbc0318 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 8d37c7047..8f74b5131 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 c2cfdaeff..80fa28734 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 6739c4bc5..b9d021d91 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 1be7a1230..f3ed1c7f5 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 4d8351def..61f00a94d 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 5c465d81c..3d9f5d9d4 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 e369cec99..9318864ab 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 0390b3a06..706c0ff89 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 d630ddfaf..691ad8e85 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 { |