From: Robert Riches on
On 2010-03-16, unruh <unruh(a)wormhole.physics.ubc.ca> wrote:
> On 2010-03-16, Bit Twister <BitTwister(a)mouse-potato.com> wrote:
>> On Mon, 15 Mar 2010 22:50:30 -0700 (PDT), yawnmoth wrote:
>>> If, in Ubuntu, you open a new terminal, do "firefox &" and then close
>>> the terminal Firefox will close, as well. Is there a way to make it
>>> so Firefox would stay open even if the Terminal from which it opened
>>> was closed?
>>
>> Have you tried nohup firefox &
>
> The problem is stdin/out/error. They are connected to the terminal. If
> you close the terminal you close these three files, and the poor program
> is suddenly left adrift. You could also try
> filefox &>/dev/null </dev/null &
> to see if that helps

Another tool for this type of situation is setsid. However, in
my experience it does not close or redirect stdin/stdout/stderr.
Also, in Ubuntu, if you setsid a process and log out from an X
session, the setsid'ed child still dies.

--
Robert Riches
spamtrap42(a)verizon.net
(Yes, that is one of my email addresses.)
From: J G Miller on
On Tue, 16 Mar 2010 15:24:05 +0000, unruh wrote:

> The problem is stdin/out/error. They are connected to the terminal. If
> you close the terminal you close these three files, and the poor program
> is suddenly left adrift.

Are you really sure that closing the terminal closes stdin, stdout, and
stderr?

From: David Brown on
On 16/03/2010 16:57, John Hasler wrote:
>> Works fine for me. I can close the terminal and firefox keeps running.
>
> The Firefox (or a script) is either detaching itself or catching SIGHUP.

Firefox likes to have a single main process handling the session. This
is started (and detached) by the first run of the firefox binary.
Subsequent calls to the firefox binary simply pass on their arguments to
the main process, which opens new tabs or windows as needed. That's how
you can run "firefox" when clicking a link in another program, and get a
new tab in an existing window instead of a whole new process.

From: Robert Riches on
On 2010-03-17, J G Miller <miller(a)yoyo.ORG> wrote:
> On Tue, 16 Mar 2010 15:24:05 +0000, unruh wrote:
>
>> The problem is stdin/out/error. They are connected to the terminal. If
>> you close the terminal you close these three files, and the poor program
>> is suddenly left adrift.
>
> Are you really sure that closing the terminal closes stdin, stdout, and
> stderr?

In at least some cases, the orphaned background process is
adopted by init. I think in at least some cases, those file
descriptors effectively get switched to /dev/null. It may vary
with shell, and any use of nohup and/or setsid.

--
Robert Riches
spamtrap42(a)verizon.net
(Yes, that is one of my email addresses.)
From: Mark Hobley on
pk <pk(a)pk.invalid> wrote:
> Works fine for me. I can close the terminal and firefox keeps running.

On older versions of Debian, I could launch most X11 based applications from
the terminal window, and when I closed the terminal windows, the X11
applications would continue to run. (They used to somehow break free from
their controlling terminal). However, on the newer (testing) versions
I have noticed that some applications no longer break free and are now tied to
their controlling terminal session, so when I close the terminal session,
the applications now become killed.

Mark.

--
Mark Hobley
Linux User: #370818 http://markhobley.yi.org/