[Pkg-privacy-commits] [msva-perl] 89/356: handle race condition with rapid subprocess death; also ensure termination of subprocess if exec itself fails.

Ximin Luo infinity0 at moszumanska.debian.org
Mon Aug 24 07:41:43 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository msva-perl.

commit c388476dfae3fa728e17962bb31df4c107ab55f6
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date:   Thu Mar 11 19:23:36 2010 -0500

    handle race condition with rapid subprocess death; also ensure termination of subprocess if exec itself fails.
---
 msva-perl | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/msva-perl b/msva-perl
index ad494f4..2a8b36d 100755
--- a/msva-perl
+++ b/msva-perl
@@ -380,8 +380,11 @@ use strict;
     my $pid = shift;
     my $server = shift;
 
+    msvalog('debug', "Subprocess %d terminated.\n", $pid);
+
     if (exists $self->{child_pid} &&
-        $self->{child_pid} == $pid) {
+        ($self->{child_pid} == 0 ||
+         $self->{child_pid} == $pid)) {
       my $exitstatus = POSIX::WEXITSTATUS($?);
       msvalog('verbose', "Subprocess %d terminated; exiting %d.\n", $pid, $exitstatus);
       $server->set_exit_status($exitstatus);
@@ -403,14 +406,16 @@ use strict;
 
     my $argcount = @ARGV;
     if ($argcount) {
+      $self->{child_pid} = 0; # indicate that we are planning to fork.
       my $fork = fork();
       if (! defined $fork) {
         msvalog('error', "could not fork\n");
       } else {
         if ($fork) {
+          msvalog('debug', "Child process has PID %d\n", $fork);
           $self->{child_pid} = $fork;
         } else {
-          msvalog('verbose', "Executing: \n");
+          msvalog('verbose', "PID %d executing: \n", $$);
           for my $arg (@ARGV) {
             msvalog('verbose', " %s\n", $arg);
           }
@@ -420,7 +425,7 @@ use strict;
             push @args, untaint($_);
           }
           $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET} = sprintf('http://localhost:%d', $self->port);
-          exec(@args);
+          exec(@args) or die;
         }
       }
     };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/msva-perl.git



More information about the Pkg-privacy-commits mailing list