diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-01-11 23:15:11 +0000 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-01-12 00:31:17 +0000 |
commit | 3fad6db8d44a435d456e9d79e2c6811ac2bc0364 (patch) | |
tree | 84d13e86fc268f59a86adbef06ca80d0a7c193cf /Debian | |
parent | 1c786a07ee01b09c1579e562e3aecea0779cc3a9 (diff) |
Dgit: forkcheck_*: break out from setup_sigwarn
Other places are going to want this too, notably END blocks.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'Debian')
-rw-r--r-- | Debian/Dgit.pm | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index be8cbee..5e0bbd5 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -36,7 +36,7 @@ BEGIN { $VERSION = 1.00; @ISA = qw(Exporter); - @EXPORT = qw(setup_sigwarn + @EXPORT = qw(setup_sigwarn forkcheck_setup forkcheck_mainprocess dep14_version_mangle debiantags debiantag_old debiantag_new server_branch server_ref @@ -81,10 +81,21 @@ sub NOCOMMITCHECK () { return 0x8; } our $debugprefix; our $debuglevel = 0; +our $forkcheck_mainprocess; + +sub forkcheck_setup () { + $forkcheck_mainprocess = $$; +} + +sub forkcheck_mainprocess () { + # You must have called forkcheck_setup or setup_sigwarn already + getppid != $forkcheck_mainprocess; +} + sub setup_sigwarn () { - our $sigwarn_mainprocess = $$; + forkcheck_setup(); $SIG{__WARN__} = sub { - die $_[0] unless getppid == $sigwarn_mainprocess; + die $_[0] if forkcheck_mainprocess; }; } |