#!/bin/ksh
-# $OpenBSD: fw_update.sh,v 1.53 2023/11/15 02:00:02 afresh1 Exp $
+# $OpenBSD: fw_update.sh,v 1.54 2023/11/15 02:03:49 afresh1 Exp $
#
# Copyright (c) 2021,2023 Andrew Hewus Fresh <afresh1@openbsd.org>
#
}
lock_db() {
+ local _waited
[ "${LOCKPID:-}" ] && return 0
# The installer doesn't have perl, so we can't lock there
$|=1;
$0 = "fw_update: lock_db";
- lock_db(0);
+ my $waited = 0;
+ package OpenBSD::FwUpdateState {
+ use parent 'OpenBSD::BaseState';
+ sub errprint ($self, @p) {
+ if ($p[0] && $p[0] =~ /already locked/) {
+ $waited++;
+ $p[0] = " " . $p[0]
+ if !$ENV{VERBOSE};
+ }
+ $self->SUPER::errprint(@p);
+ }
+
+ }
+ lock_db(0, 'OpenBSD::FwUpdateState');
- say $$;
+ say "$$ $waited";
# Wait for STDOUT to be readable, which won't happen
# but if our parent exits unexpectedly it will close.
EOL
set +o monitor
- read -rp LOCKPID
+ read -rp LOCKPID _waited
+
+ if ((_waited)); then
+ ! ((VERBOSE)) && status "${0##*/}:"
+ fi
return 0
}