Score:2

Ubuntu 20.04.3 Problems running Firefox from terminal

ru flag

I am a fresh user of Ubuntu 20.04.3. I came across a problem with running firefox web browser from the terminal.

When I type 'firefox' in the terminal I get the message:

ATTENTION: default value of option mesa_glthread overridden by environment.

ATTENTION: default value of option mesa_glthread overridden by environment.

ATTENTION: default value of option mesa_glthread overridden by environment.

ATTENTION: default value of option mesa_glthread overridden by environment.

Firefox eventually launches, but if I close the terminal window it also shuts down my firefox.

us flag
Please edit the question to add the terminal outputs as code, instead of posting screenshots.
Score:3
cn flag

There are a few ways to make your background process resilient to hangup first, you have nohup which instructs the signal function to ignore SIGHUP before replacing itself with the new process (execvp). However, for applications that re-implements signal handling, this is not possible.

Next, the setsid command works much the same way, but instead of manipulating the signal, setsid() is used to create a new session, this will not make your application immune, but at least it will not receive any more signal from the terminal. Now, these two commands can be combined, e.i., if SIGHUP is honored, or nohup will be redundant.

Lastly, with disown you can either remove your application from active jobs or mark the application using -h to not receive SIGHUP sent from the shell. Now, as with setsid, this will not make your application immune, but as long as SIGHUP is not sent directly to the process, you should be fine.

firefox &>/dev/null & disown

You may also disown a running application.

$ firefox
ctrl + z
^Z
[1]+  Stopped                 firefox
$ bg
$ disown

disown also takes either jobspec or pid as an argument.

sudodus avatar
jp flag
+1, Thanks, this is a very useful answer :-)
Score:2
us flag

If you want to be able to close the terminal after launching the graphical software you need to use --detach.

Example:

firefox --detach
N0rbert avatar
zw flag
I do not see `--detach` on [firefox's man-page](http://manpages.ubuntu.com/manpages/focal/en/man1/firefox.1.html). Do you mean `Ctrl`+`Z`, followed by `bg` ?
sudodus avatar
jp flag
Do you know the difference between using `firefox --detach &` and `nohup firefox &` (except that nohup will save terminal output to `nohup.out`)?
sudodus avatar
jp flag
@N0rbert, you are right, but it works anyway.
ChanganAuto avatar
us flag
@N0rbert This is the same parameter used by the Firefox ESR based TOR Bundle browser, that why it works and is simple enough for the OP to use.
ru flag
@ChanganAuto after using firefox --detach, on an attempt to close terminal, it still closes the web browser
ChanganAuto avatar
us flag
@kowczarek Simply put that's not possible. Either you typed something wrong or maybe your trying to run it as root, something you should never do.
sudodus avatar
jp flag
@kowczarek, `--detach` works for me, but something must be different between our systems. Anyway, please try `nohup firefox &` and let us know how that works, when you close your terminal window. - By the way, how do you close your terminal?
ru flag
@sudodus I have tried 'nohup firefox &' it launches the firefox and I am able to close terminal, but when I do it likes kill my firefox session and I get this message: "Gah. Your tab just crashed. We can help! Choose Restore This Tab to reload the page." And for your question 'how do I close terminal' I just press the X in the upper right corner, is it a bad way to do it? :(
bac0n avatar
cn flag
usually, when you really want to detach a process I think `setsid` works best.
sudodus avatar
jp flag
@kowczarek, This is strange. I tested in my main computer with 18.04.x LTS, where it works. Now I tested in a test system with an up to date standard Ubuntu 20.04.3, and I get the same as you. It ***should*** be OK to close the terminal window with the x button :-( But when I closed the terminal by typing `exit` (from bash in the terminal window), firefox survived without complaint :-)
sudodus avatar
jp flag
See [this link](https://paste.ubuntu.com/p/G4wNMBRYMY/) to the Ubuntu pastebin with the output to the Firefox tab and to `nohup.out`, when exiting from `gnome-terminal' in Ubuntu 20.04.3 LTS.
sudodus avatar
jp flag
You are right @bac0n, `setsid firefox &` works. Firefox survives when exiting from `gnome-terminal' in Ubuntu 20.04.3 LTS (also when pressing the x button). Can you explain the difference? I suggest that you write an answer (and I promise to upvote it).
bac0n avatar
cn flag
maybe `setsid -f firefox` works.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.