Ubuntu 20.04.3 Problems running Firefox from terminal

Solution 1:

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.

Solution 2:

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

Example:

firefox --detach