How to gently kill Firefox process on Linux/OS X

前端 未结 7 1420
盖世英雄少女心
盖世英雄少女心 2021-02-08 06:02

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

相关标签:
7条回答
  • 2021-02-08 06:17

    A bit more gentle

    As @skybert indicated in the comment, you can

    set browser.sessionstore.resume_from_crash to false.

    in about:config, which

    will rid you of the "Ups, something went wrong ..." message.

    To get rid of the safe-mode message, you can set the config

    toolkit.startup.max_resumed_crashes to -1

    or (just set) the environment variable 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.

    This is no more "gentle" than your solution, but it fixes the "Safe Mode" message:

    Source: https://support.mozilla.org/en-US/questions/817752

    0 讨论(0)
  • 2021-02-08 06:26

    You can first get the Pid of firefox with

    pgrep firefox
    

    and after use kill to stop firefox kill [pid]

    kill `pgrep firefox`
    
    0 讨论(0)
  • 2021-02-08 06:26

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

        xkill
    
    0 讨论(0)
  • 2021-02-08 06:29

    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.

    0 讨论(0)
  • 2021-02-08 06:32

    You can use pkill with the process name:

    pkill -f firefox
    
    0 讨论(0)
  • 2021-02-08 06:32

    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.
    0 讨论(0)
提交回复
热议问题