Lately I run Firefox almost exclusively from on one of my Debian laptops (which run testing). Occasionally (~monthly) my desktop/tty7 hangs, in which case I usually can goto tty1 and sudo shutdown -[whatever] now . Unfortunately this does not cause Firefox to shut down as cleanly as I'd like: notably, when I bring it back up after OS restart, I must restore a crashed session. Which usually is not a problem, but sometimes is.

ISTM, for this usecase, I should be able to utter something (before shutdown) from tty1 to tell Firefox to shutdown cleanly. I know what to tell Emacs, but not what to tell Firefox. How to do this? FWIW, the following do not work:

  1. killall -HUP firefox1

When I do that in (the bash terminal @) tty1, and goto tty7, Firefox is indeed gone. But when I restart Firefox (in tty7), Firefox comes up with dialog title=Session Manager - Restore after Crash and offers a crashed session.

  1. killall -SIGHUP $(pidof firefox)

(Note: I substituted $() for the backticks used in the candidate answer below to make Markdown happy, but when I ran from tty1, I used the backticks, though I'm quite sure bash does not care.) This does not work at all for me, but I'm not sure why: when I do the following in tty1,

$ killall -SIGHUP `pidof firefox`
24586: no process found
$ pidof firefox
$ pgrep -l firefox
24586 firefox

... and then goto tty7, Firefox is still there.

  1. pkill -HUP firefox

Results identical to item#=1 above.

  • killall expects a name or pattern, NOT a pid. kill -HUP $(pidof xyz) does the same as killall -HUP xyz (and vice versa!) – dave_thompson_085 Dec 3 '15 at 5:36

killall -HUP firefox should do it gracefully.

| improve this answer | |
  • alas, no: when I (1) killall -HUP firefox in tty1 (2) restart Firefox in tty7, I get 'Your last session Crashed!' – TomRoche Nov 24 '15 at 6:34

The following command will solve your issue:

killall -SIGHUP `pidof firefox`

But how to handle the problem that your tty7 hangs after one month of use? Rather than reboot or shutdown, I would suggest

sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'

This will drop OS caches, thus releasing more memory for applications.

| improve this answer | |
  • Alas, no, the killall commandline fails as noted in my updated question. But thanks for the drop_caches: I'm not sure that it will fix the tty7 problem (I'll try that next time), but in my current LMDE/Cinnamon session, it did increase free memory by 30%! I suspect this is because Cinnamon caches fairly aggressively, but ICBW. – TomRoche Dec 3 '15 at 4:48

Another option:

wmctrl -c "Mozilla Firefox"


wmctrl -c "Firefox"

Reference: https://linux.die.net/man/1/wmctrl

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.