2

When I had loads of firefox windows open and wanted to close them quickly I did
killall firefox
using killall from the psmisc package in Ubuntu.

Nothing happened.

I looked in the list of my processes and there were many lines of the form

alle_meije     55061    7662  0 01:16 ?        00:00:31 /usr/lib/firefox/firefox -contentproc -childID 126 -isForBrowser -prefsLen 9704 -prefMapSize 254479 -jsInitLen 279340 -parentBuildID 20220106144528 -appDir /usr/lib/firefox/browser 7662 true tab

so, firefox being the 'basename' of the executable there, I would have expected these to be killed.

Sure enough, doing it by hand using
kill $( ps -fu $USER | grep firefox | awk '{print $2}' )
did close all these windows. Does anyone know why the same does not happen with killall?

2 Answers2

4

killall firefox-bin works for me but then I use the official Firefox distribution.

As mentioned in the comments, pkill -f firefox should work as well.


-f The pattern is normally only matched against the process name. When -f is set, the full command line is used.

  • Thanks, this does work. The strange thing is, killall now works as well (in a new login). Finding a way to kill the windows was not the problem, I just wondered what could cause this. The only possible cause I have come up with is that previously, I had done suspend/continue a few times. As to how, no idea... – alle_meije Feb 21 '22 at 09:21
-4

When I want to kill all of a specific process I use this script. I am sure there are better ways. But it works for things like firefox-esr. firefox-bin, firefox. Processes that are basically identical but may have different names. Be careful though, you can kill processes you don't want!

ps -e | grep <process name> | awk '{print $1;}' | xargs kill

In your case:

ps -e | grep firefox | awk '{print $1;}' | xargs kill