diff options
author | 2018-02-10 10:08:05 +0000 | |
---|---|---|
committer | 2018-02-10 10:08:05 +0000 | |
commit | 030a7b9c35c25d90a71f10cfde4acb6f14c2a966 (patch) | |
tree | ba74f73e94f5c9cedb657055415a627b5d83b5b6 | |
parent | print etherip on ipv6. (diff) | |
download | wireguard-openbsd-030a7b9c35c25d90a71f10cfde4acb6f14c2a966.tar.xz wireguard-openbsd-030a7b9c35c25d90a71f10cfde4acb6f14c2a966.zip |
rewrite file around fh_file, temp file creation with signal protection,
to be used to get anon temp files for https
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Temp.pm | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Temp.pm b/usr.sbin/pkg_add/OpenBSD/Temp.pm index 76e59615044..da5b628a09c 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.27 2015/03/04 13:55:32 espie Exp $ +# $OpenBSD: Temp.pm,v 1.28 2018/02/10 10:08:05 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -64,8 +64,9 @@ sub dir return "$dir/"; } -sub file +sub fh_file { + my ($stem, $cleanup) = @_; my $caught; my $h = sub { $caught = shift; }; my ($fh, $file); @@ -76,15 +77,20 @@ sub file local $SIG{'HUP'} = $h; local $SIG{'KILL'} = $h; local $SIG{'TERM'} = $h; - ($fh, $file) = permanent_file($tempbase, "pkgout"); + ($fh, $file) = permanent_file($tempbase, $stem); if (defined $file) { - $files->{$file} = $$; + &$cleanup($file); } } if (defined $caught) { kill $caught, $$; } - return $file; + return ($fh, $file); +} + +sub file +{ + return (fh_file("pkgout", sub { $files->{shift} = $$; })) [1]; } sub reclaim |