diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2006-03-07 14:00:49 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2006-03-07 14:00:49 +0000 |
commit | acff5bd259afcdf86938fa7d9d2865c823da2cbc (patch) | |
tree | 1f0e589f60608312a397da71a81d67128fc6186a /usr.sbin | |
parent | bb0696cde502ae6fba31aec6f0064569ba8201ae (diff) |
rendez-vous with subchild through signal USR1.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm index a1a79950753..fbe09ebd058 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SCP.pm,v 1.3 2006/03/07 13:25:05 espie Exp $ +# $OpenBSD: SCP.pm,v 1.4 2006/03/07 14:00:48 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -64,6 +64,11 @@ sub grab_object my $cmdfh = $self->{cmdfh}; my $getfh = $self->{getfh}; + $SIG{'USR1'} = sub { + kill USR1 => $object->{parent}; + exit(1); + }; + print $cmdfh "ABORT\n"; local $_; while (<$getfh>) { @@ -71,7 +76,6 @@ sub grab_object } print $cmdfh "GET ", $self->{path}.$object->{name}, "\n"; close($cmdfh); - $_ = <$getfh>; chomp; if (m/^ERROR:/) { @@ -99,6 +103,19 @@ sub grab_object } } +sub pkg_copy +{ + my ($self, $in, $object) = @_; + + $SIG{'USR1'} = sub { + close($in); + kill USR1 => $object->{parent}; + exit(1); + }; + + $self->SUPER::pkg_copy($in, $object); +} + sub _new { my ($class, $baseurl) = @_; @@ -162,15 +179,16 @@ sub finish_and_close sub close { my ($self, $object, $hint) = @_; - close($object->{fh}) if defined $object->{fh}; # XXX we have to make sure the grand-child is dead. if (defined $object->{pid2}) { - my $sleep = 0.05; - while (kill 0 => $object->{pid2}) { - sleep($sleep); - $sleep *= 2; + my $received = 0; + local $SIG{'USR1'} = sub { print STDERR "Received USR1\n"; $received = 1; }; + kill USR1 => $object->{pid2}; + while (!$received) { + sleep 0.01; } } + close($object->{fh}) if defined $object->{fh}; $self->parse_problems($object->{errors}, $hint) if defined $object->{errors}; |