I'm dealing with an application, that brings up a multitude of separate processes, some of which sometimes do not go away, when asked politely -- by using the application's own means.
Which means, they have to be evicted rudely (with SIGTERM
) and then, for the particularly stubborn ones -- brutally (with SIGKILL
).
The trouble is finding them all... How do you list all processes, which consider a given directory -- or a subdirectory thereof -- its working-directory (cwd
)?
The best method I was able to come up with was to invoke: lsof -b -w -u $(whoami)
, then parsing the last column looking for my directory, and then running the second column (the PID
) through sort -u
.
Is there, perhaps, anything better?