get trace to cleanup its children as well (pass them an INT signal)
This commit is contained in:
parent
dde7a1703d
commit
b774514f73
@ -1,7 +1,7 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: dpb,v 1.128 2019/05/12 10:37:04 espie Exp $
|
||||
# $OpenBSD: dpb,v 1.129 2019/05/15 13:51:07 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -98,23 +98,25 @@ sub affinityclass
|
||||
my $subdirlist = {};
|
||||
|
||||
my $master_pid = $$;
|
||||
|
||||
my $cleanup =
|
||||
sub {
|
||||
my $S = shift;
|
||||
if ($$ == $master_pid) {
|
||||
$> = 0;
|
||||
DPB::Core->cleanup($S // "INT", 0);
|
||||
}
|
||||
};
|
||||
|
||||
for my $S (qw(INT HUP TERM QUIT)) {
|
||||
$SIG{$S} = sub {
|
||||
if ($$ == $master_pid) {
|
||||
$> = 0;
|
||||
DPB::Core->cleanup($S, 0);
|
||||
# my $g = getpgrp();
|
||||
# kill $S => -$g; # or ask Core.pm ?
|
||||
} else {
|
||||
# print STDERR "Entering $S handler from $$ ($master_pid)\n";
|
||||
# print STDERR join("\n", DPB::Trace::trace_message()), "\n";
|
||||
}
|
||||
&$cleanup($S);
|
||||
$SIG{$S} = 'DEFAULT';
|
||||
kill $S => $$;
|
||||
};
|
||||
}
|
||||
|
||||
DPB::Trace->setup(\%SIG);
|
||||
DPB::Trace->setup(\%SIG, $cleanup);
|
||||
|
||||
my $state = DPB::State->new;
|
||||
$state->handle_options;
|
||||
|
@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Trace.pm,v 1.2 2015/10/30 09:46:45 espie Exp $
|
||||
# $OpenBSD: Trace.pm,v 1.3 2019/05/15 13:51:07 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2015 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -50,11 +50,12 @@ sub trace_message
|
||||
return $msg;
|
||||
}
|
||||
|
||||
my ($reporter, $sig, $olddie, $oldwarn, $logfile);
|
||||
my ($reporter, $sig, $olddie, $oldwarn, $logfile, $cleanup);
|
||||
sub setup
|
||||
{
|
||||
my $class = shift;
|
||||
$sig = shift;
|
||||
$cleanup = shift;
|
||||
$olddie = $SIG{__DIE__};
|
||||
$oldwarn = $SIG{__WARN__};
|
||||
$sig->{__WARN__} = sub {
|
||||
@ -88,6 +89,7 @@ sub setup
|
||||
print $logfile $msg;
|
||||
print $logfile '-'x70, "\n";
|
||||
}
|
||||
&$cleanup;
|
||||
die $msg;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user