如何在 Linux/OS X 上轻轻杀死 Firefox 进程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19516212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to gently kill Firefox process on Linux/OS X
提问by martin
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.
我正在使用 Firefox 进行一些自动化,虽然我可以从 shell 打开 Firefox 窗口,但我无法正确终止它。如果我在下一次打开一个新的 Firefox 窗口时kill
使用kill -3
或kill -2
命令处理Firefox,它会询问我是否要在安全模式下运行。我知道调用kill -9
可能会混淆 Firefox,因此它会尝试在安全模式下运行,但-3
应该没问题。
Do you have any idea how to gently tell Firefox to close properly?
您知道如何轻轻地告诉 Firefox 正确关闭吗?
回答by anubhava
You can use pkill
with the process name:
您可以使用pkill
进程名称:
pkill -f firefox
回答by anishsane
How about
怎么样
wmctrl -c "Mozilla Firefox"
?
?
Is it what you want?
是你想要的吗?
NOTEs:
笔记:
- This command may need to be fired in same DISPLAY & probably same virtual desktop, on which your firefox is running.
- Only first matching window will be closed. You may need to loop this command.
- 此命令可能需要在运行 firefox 的同一个 DISPLAY 和可能同一个虚拟桌面中触发。
- 只会关闭第一个匹配窗口。您可能需要循环此命令。
回答by Victor
You can first get the Pid of firefox with
你可以先得到firefox的pid
pgrep firefox
and after use kill to stop firefox kill [pid]
并在使用 kill 停止 firefox kill [pid] 之后
kill `pgrep firefox`
回答by chepner
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):
在 Mac OS X 中,您可以使用 AppleScript 关闭它(根据需要调整应用程序名称;我没有安装 FireFox 进行测试):
$ 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.
这应该触发退出菜单命令触发的相同事件,因此 FireFox 应该完全关闭。
Obviously, this won't work in Linux.
显然,这在 Linux 中是行不通的。
回答by Ahmed Lotfy
For Firefox in OSX:
对于 OSX 中的 Firefox:
killall 'firefox'
回答by serv-inc
A bit more gentle
温柔一点
As @skybert indicated in the comment, you can
正如@skybert 在评论中指出的那样,您可以
set
browser.sessionstore.resume_from_crash
tofalse
.
设置
browser.sessionstore.resume_from_crash
为false
。
in about:config
, which
在about:config
,其中
will rid you of the "Ups, something went wrong ..." message.
将使您摆脱“UPS,出了点问题......”的消息。
To get rid of the safe-modemessage, you can set the config
要摆脱安全模式消息,您可以设置配置
toolkit.startup.max_resumed_crashes
to-1
toolkit.startup.max_resumed_crashes
到-1
or (just set) the environment variable MOZ_DISABLE_AUTO_SAFE_MODE
.
或(只需设置)环境变量MOZ_DISABLE_AUTO_SAFE_MODE
。
Less gentle
不太温柔
In lack of a better solution, you can remove sessionstore.js
from the profile folder after the killall
.
如果没有更好的解决方案,您可以sessionstore.js
在killall
.
This is no more "gentle" than your solution, but it fixes the "Safe Mode" message:
这并不比您的解决方案更“温和”,但它修复了“安全模式”消息:
回答by Deepak Singh
First Run xkill command after that click on window which one you want close
在单击要关闭的窗口后首先运行 xkill 命令
xkill