I'm spawning a fish
shell as a background job and from it I'm spawning inotifywait
(a process that watches a specified file and returns only once it has been changed).
Later on, however, at an unspecified point in time (at which point it's not guaranteed that inotifywait
had returned), I'm killing the fish
shell that spawned inotifywait
.
My goal is for inotifywait
to terminate automatically as soon as the PPID that spawned it terminates. Is there any way to do this?
fish -c "inotifywait -qq $somefile && ..." &
# time passes, inotifywait hasn't returned
kill -15 (jobs -lp)
# the fish process is now terminated, but inoyifywait remains
The temporary hack I'm using right now is to simply update the access time of the file being watched (with a utility such as touch
) so that inotifywait
would finally return.
I'm using fish 3.0.1
on linux 4.20.11
.