Kaynağa Gözat

Dpkg::IPC: Kill the process when reaching timeout in wait_child()

If we reached the timeout while waiting for the process to terminate,
we should not leave the dangling process running astray.
Guillem Jover 11 yıl önce
ebeveyn
işleme
5f5f7c3b90
2 değiştirilmiş dosya ile 9 ekleme ve 3 silme
  1. 1 0
      debian/changelog
  2. 8 3
      scripts/Dpkg/IPC.pm

+ 1 - 0
debian/changelog

@@ -106,6 +106,7 @@ dpkg (1.18.0) UNRELEASED; urgency=low
       preserving the insertion order, which is not reproducible with parallel
       builds. Reported by Jérémy Bobbio <lunar@debian.org>.
     - Add new filter() method to Dpkg::Substvars.
+    - Kill the process when reaching timeout in Dpkg::IPC::wait_child().
   * Test suite:
     - Check perl code compilation, warnings and strictness.
     - Fix dpkg-divert unit test to work on BSD «rm -rf» that cannot traverse

+ 8 - 3
scripts/Dpkg/IPC.pm

@@ -20,7 +20,7 @@ package Dpkg::IPC;
 use strict;
 use warnings;
 
-our $VERSION = '1.01';
+our $VERSION = '1.02';
 our @EXPORT = qw(
     spawn
     wait_child
@@ -364,8 +364,8 @@ non-zero return code).
 
 =item timeout
 
-Set a maximum time to wait for the process, after that fail
-with an error message.
+Set a maximum time to wait for the process, after that kill the process and
+fail with an error message.
 
 =back
 
@@ -383,6 +383,7 @@ sub wait_child {
     };
     if ($@) {
         die $@ unless $@ eq "alarm\n";
+        kill 'TERM', $pid;
         error(P_("%s didn't complete in %d second",
                  "%s didn't complete in %d seconds",
                  $opts{timeout}),
@@ -400,6 +401,10 @@ __END__
 
 =head1 CHANGES
 
+=head2 Version 1.02
+
+Change options: wait_child() now kills the process when reaching the 'timeout'.
+
 =head2 Version 1.01
 
 New options: spawn() now accepts 'sig' and 'delete_sig'.