3

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
24586
$ 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
0

killall -HUP firefox should do it gracefully.

  • 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
0

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.

  • 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
0

Another option:

wmctrl -c "Mozilla Firefox"

or

wmctrl -c "Firefox"

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

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.