On 8/22/23 22:55, Andrew Hewus Fresh wrote: > I noticed this when testing how signal handling worked in fw_update, it > turns out that if you `pkill -KILL -f fw_update` it may leave behind a perl > process that is locking the package database. Instead of just waiting > to be killed, we can have that process check to see if its parent is > still around and exit if not. > > Is there a more appropriate solution to this? > What's the right way to notice your parent exited? > > Comments, OK? > > Index: fw_update.sh > =================================================================== > RCS file: /cvs/src/usr.sbin/fw_update/fw_update.sh,v > retrieving revision 1.44 > diff -u -p -r1.44 fw_update.sh > --- fw_update.sh 12 Dec 2022 02:30:51 -0000 1.44 > +++ fw_update.sh 23 Aug 2023 02:47:54 -0000 > @@ -221,10 +221,15 @@ lock_db() { > > $|=1; > > + $0 = "fw_update: lock_db"; > lock_db(0); > > say $$; > - sleep; > + > + # If our parent exits unexpectedly, > + # ppid will become init and we should exit. > + my $parent = getppid; > + sleep 1 while getppid == $parent;
If it will always become init, then this should also contain a check that $parent != 1 > EOL > set +o monitor > >