From 648823881a320c8e6cf59a421d8f08750a657902 Mon Sep 17 00:00:00 2001 From: afresh1 Date: Thu, 31 Aug 2023 19:00:00 +0000 Subject: [PATCH] Exit fw_update(8) lock_db subprocess when parent exits If fw_update exits unexpectedly the package database would never unlock. select solution from millert@ --- usr.sbin/fw_update/fw_update.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh index efc16b782f3..7b386a3f05a 100644 --- a/usr.sbin/fw_update/fw_update.sh +++ b/usr.sbin/fw_update/fw_update.sh @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: fw_update.sh,v 1.45 2023/08/31 18:19:21 afresh1 Exp $ +# $OpenBSD: fw_update.sh,v 1.46 2023/08/31 19:00:00 afresh1 Exp $ # # Copyright (c) 2021,2023 Andrew Hewus Fresh # @@ -259,18 +259,23 @@ lock_db() { [ -e /usr/bin/perl ] || return 0 set -o monitor - perl <<'EOL' |& - use v5.16; - use warnings; + perl <<-'EOL' |& no lib ('/usr/local/libdata/perl5/site_perl'); + use v5.36; use OpenBSD::PackageInfo qw< lock_db >; $|=1; + $0 = "fw_update: lock_db"; lock_db(0); say $$; - sleep; + + # Wait for STDOUT to be readable, which won't happen + # but if our parent exits unexpectedly it will close. + my $rin = ''; + vec($rin, fileno(STDOUT), 1) = 1; + select $rin, '', '', undef; EOL set +o monitor -- 2.20.1