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?

1

2 Answers 2

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.

1
  • 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
    Commented Feb 21, 2022 at 9: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
4
  • 1
    Why so complicated? I'm giving -1. In addition, it uses 4 different programs to achieve such a simplistic job... Commented Feb 16, 2022 at 14:59
  • 3
    On my system, at least, ps -e does not report firefox but instead shows it as GeckoMain. More importantly, and as you point out, this can kill completely unrelated processes!
    – terdon
    Commented Feb 16, 2022 at 15:52
  • @terdon The more you know! Commented Feb 16, 2022 at 15:54
  • 1
    Have a look at pgrep -f and pkill -f, those will be better tools for this sort of thing.
    – terdon
    Commented Feb 16, 2022 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .