summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2019-07-10 09:34:10 +0000
committerMarc Espie <espie@cvs.openbsd.org>2019-07-10 09:34:10 +0000
commit0469ecfbfbd0aad581ba39c819af329f174c9e47 (patch)
treee2ecb64fc7db24b647cd0e55413ec46d857c5d2a
parentd0845a579941c4b47b60dcad31249c8bfed793a5 (diff)
deal with temp dir creation failures.
make the END{} block transparent for exit
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Temp.pm14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Temp.pm b/usr.sbin/pkg_add/OpenBSD/Temp.pm
index 8ed79b5a863..7da540ebbd8 100644
--- a/usr.sbin/pkg_add/OpenBSD/Temp.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Temp.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Temp.pm,v 1.33 2019/07/07 12:42:54 espie Exp $
+# $OpenBSD: Temp.pm,v 1.34 2019/07/10 09:34:09 espie Exp $
#
# Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org>
#
@@ -41,7 +41,9 @@ my $cleanup = sub {
};
END {
+ my $r = $?;
&$cleanup;
+ $? = $r;
}
OpenBSD::Handler->register($cleanup);
@@ -58,12 +60,18 @@ sub dir
local $SIG{'KILL'} = $h;
local $SIG{'TERM'} = $h;
$dir = permanent_dir($tempbase, "pkginfo");
- $dirs->{$dir} = $$;
+ if (defined $dir) {
+ $dirs->{$dir} = $$;
+ }
}
if (defined $caught) {
kill $caught, $$;
}
- return "$dir/";
+ if (defined $dir) {
+ return "$dir/";
+ } else {
+ return undef;
+ }
}
sub fh_file