How to gently kill Firefox process on Linux/OS X

2019-03-20 06:44发布

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?

7条回答
放荡不羁爱自由
2楼-- · 2019-03-20 07:18

First Run xkill command after that click on window which one you want close

    xkill
查看更多
Fickle 薄情
3楼-- · 2019-03-20 07:19

You can use pkill with the process name:

pkill -f firefox
查看更多
淡お忘
4楼-- · 2019-03-20 07:20

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.
查看更多
Fickle 薄情
5楼-- · 2019-03-20 07:21

You can first get the Pid of firefox with

pgrep firefox

and after use kill to stop firefox kill [pid]

kill `pgrep firefox`
查看更多
Ridiculous、
6楼-- · 2019-03-20 07:31

For Firefox in OSX:

killall 'firefox'
查看更多
聊天终结者
7楼-- · 2019-03-20 07:32

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.

查看更多
登录 后发表回答