Explorar o código

Dpkg::IPC: Add support for sig and delete_sig spawn() options

Guillem Jover %!s(int64=12) %!d(string=hai) anos
pai
achega
747ec69e69
Modificáronse 2 ficheiros con 36 adicións e 1 borrados
  1. 1 0
      debian/changelog
  2. 35 1
      scripts/Dpkg/IPC.pm

+ 1 - 0
debian/changelog

@@ -74,6 +74,7 @@ dpkg (1.17.11) UNRELEASED; urgency=low
   * Remove unused pkglibdir variable from libdpkg.pc.in.
   * Remove unused pkglibdir variable from libdpkg.pc.in.
   * Perl modules:
   * Perl modules:
     - Add new set_as_auto() method to Dpkg::Substvars.
     - Add new set_as_auto() method to Dpkg::Substvars.
+    - Add support for sig and delete_sig spawn() options in Dpkg::IPC.
   * Mark Format and Installed-Size as automatic substvars in dpkg-genchanges
   * Mark Format and Installed-Size as automatic substvars in dpkg-genchanges
     and dpkg-gencontrol respectively.
     and dpkg-gencontrol respectively.
   * Warn on usage of deprecated Source-Version substvar.
   * Warn on usage of deprecated Source-Version substvar.

+ 35 - 1
scripts/Dpkg/IPC.pm

@@ -1,5 +1,6 @@
 # Copyright © 2008-2009 Raphaël Hertzog <hertzog@debian.org>
 # Copyright © 2008-2009 Raphaël Hertzog <hertzog@debian.org>
 # Copyright © 2008 Frank Lichtenheld <djpig@debian.org>
 # Copyright © 2008 Frank Lichtenheld <djpig@debian.org>
+# Copyright © 2008-2010,2012-2014 Guillem Jover <guillem@debian.org>
 #
 #
 # This program is free software; you can redistribute it and/or modify
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # it under the terms of the GNU General Public License as published by
@@ -19,7 +20,7 @@ package Dpkg::IPC;
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
 
 
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
@@ -127,6 +128,16 @@ hash before calling exec. This allows exporting environment variables.
 Array reference. The child process will remove all environment variables
 Array reference. The child process will remove all environment variables
 listed in the array before calling exec.
 listed in the array before calling exec.
 
 
+=item sig
+
+Hash reference. The child process will populate %SIG with the items of the
+hash before calling exec. This allows setting signal dispositions.
+
+=item delete_sig
+
+Array reference. The child process will reset all signals listed in the
+array to their default dispositions before calling exec.
+
 =back
 =back
 
 
 =cut
 =cut
@@ -179,6 +190,14 @@ sub _sanity_check_opts {
 	croak 'parameter delete_env must be an array reference';
 	croak 'parameter delete_env must be an array reference';
     }
     }
 
 
+    if (exists $opts{sig} and ref($opts{sig}) ne 'HASH') {
+	croak 'parameter sig must be a hash reference';
+    }
+
+    if (exists $opts{delete_sig} and ref($opts{delete_sig}) ne 'ARRAY') {
+	croak 'parameter delete_sig must be an array reference';
+    }
+
     return %opts;
     return %opts;
 }
 }
 
 
@@ -238,6 +257,15 @@ sub spawn {
 	if ($opts{delete_env}) {
 	if ($opts{delete_env}) {
 	    delete $ENV{$_} foreach (@{$opts{delete_env}});
 	    delete $ENV{$_} foreach (@{$opts{delete_env}});
 	}
 	}
+	# Define signal dispositions.
+	if ($opts{sig}) {
+	    foreach (keys %{$opts{sig}}) {
+		$SIG{$_} = $opts{sig}{$_};
+	    }
+	}
+	if ($opts{delete_sig}) {
+	    delete $SIG{$_} foreach (@{$opts{delete_sig}});
+	}
 	# Change the current directory
 	# Change the current directory
 	if ($opts{chdir}) {
 	if ($opts{chdir}) {
 	    chdir($opts{chdir}) or syserr(_g('chdir to %s'), $opts{chdir});
 	    chdir($opts{chdir}) or syserr(_g('chdir to %s'), $opts{chdir});
@@ -365,6 +393,12 @@ __END__
 
 
 =back
 =back
 
 
+=head1 CHANGES
+
+=head2 Version 1.01
+
+New options: spawn() now accepts 'sig' and 'delete_sig'.
+
 =head1 AUTHORS
 =head1 AUTHORS
 
 
 Written by Raphaël Hertzog <hertzog@debian.org> and
 Written by Raphaël Hertzog <hertzog@debian.org> and