Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to gently kill Firefox process on Linux/OS X

I'm doing some automation with Firefox and although I can open Firefox window from shell, I'm not able to terminate it properly. If I kill Firefox process with kill -3 or kill -2 command the next time I open a new Firefox window it asks me if I want to run in safe-mode. I understand that calling kill -9 could confuse Firefox so it would try to run in safe-mode but -3 should be fine.

Do you have any idea how to gently tell Firefox to close properly?

like image 726
martin Avatar asked Oct 22 '13 11:10

martin


4 Answers

You can use pkill with the process name:

pkill -f firefox
like image 197
anubhava Avatar answered Oct 13 '22 21:10

anubhava


For Firefox in OSX:

killall 'firefox'
like image 38
Ahmed Lotfy Avatar answered Sep 18 '22 04:09

Ahmed Lotfy


How about

wmctrl -c "Mozilla Firefox"

?

Is it what you want?

NOTEs:

  1. This command may need to be fired in same DISPLAY & probably same virtual desktop, on which your firefox is running.
  2. Only first matching window will be closed. You may need to loop this command.
like image 8
anishsane Avatar answered Oct 13 '22 21:10

anishsane


In Mac OS X, you could use AppleScript to close it (adjust the application name as necessary; I don't have FireFox installed to test):

$ osascript -e 'tell application "FireFox"
quit
end tell'

This should trigger the same event that the Quit menu command triggers, so FireFox should shut down cleanly.

Obviously, this won't work in Linux.

like image 3
chepner Avatar answered Oct 13 '22 20:10

chepner