~mdw
/
with-authinfo-kludge
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
with-authinfo-kludge: Add machinery to restore signals in child processes.
[with-authinfo-kludge]
/
with-authinfo-kludge
diff --git
a/with-authinfo-kludge
b/with-authinfo-kludge
index
3cdefe3
..
4317d8d
100755
(executable)
--- a/
with-authinfo-kludge
+++ b/
with-authinfo-kludge
@@
-173,10
+173,20
@@
sub write_to_file ($$) {
rename $new, $file or sysfail "failed to rename `$new' to `$file': $!";
}
rename $new, $file or sysfail "failed to rename `$new' to `$file': $!";
}
+my %OLDSIGS;
+sub set_sighandler ($$) {
+ my ($sig, $handler) = @_;
+ unless (exists $OLDSIGS{$sig}) { $OLDSIGS{$sig} = $SIG{$sig}; }
+ $SIG{$sig} = $handler;
+}
+
my $INKIDP = 0;
sub myfork () {
my $kid = fork;
my $INKIDP = 0;
sub myfork () {
my $kid = fork;
- if (defined $kid && !$kid) { $INKIDP = 1; }
+ if (defined $kid && !$kid) {
+ $INKIDP = 1;
+ for my $sig (keys %OLDSIGS) { $SIG{$sig} = $OLDSIGS{$sig}; }
+ }
return $kid;
}
return $kid;
}
@@
-747,7
+757,7
@@
sub wait_for_ssh () {
else { inform " all tunnels started ok"; }
}
else { inform " all tunnels started ok"; }
}
-
$SIG{"CHLD"} =
sub {
+
set_sighandler "CHLD",
sub {
KID: for (;;) {
defined (my $kid = waitpid -1, WNOHANG)
or sysfail "failed to reap child: $!";
KID: for (;;) {
defined (my $kid = waitpid -1, WNOHANG)
or sysfail "failed to reap child: $!";