Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What's different between background process and daemon process?

0 views
Skip to first unread message

Charley

unread,
Dec 7, 2001, 3:19:39 AM12/7/01
to
Hi.

Case 1.
I talk to login shell that execute foo in background and then logout.
The "foo" runs forever.

Case 2.
I run the foo as daemon process and logout.
The daemon "foo" runs forever.

What's different between them?

Please explain the concept of daemon in addition.

Thanks in advance!!


Charley

unread,
Dec 7, 2001, 3:55:04 AM12/7/01
to
"Charley" <cha...@serome.co.kr> wrote in message
news:vY_P7.399$H3.4...@news.bora.net...

Hi again.

When make daemon, why doesn't leave the execution file
session leader and group leader?

Stevens makes daemon as child of new session not session leader.

If I make daemon session leader what happens?

Best regards!


Nils O. Selåsdal

unread,
Dec 7, 2001, 4:03:24 AM12/7/01
to
On Fri, 07 Dec 2001 08:19:39 GMT, Charley <cha...@serome.co.kr> wrote:
>Hi.
>
>Case 1.
>I talk to login shell that execute foo in background and then logout.
>The "foo" runs forever.
>
>Case 2.
>I run the foo as daemon process and logout.
>The daemon "foo" runs forever.
>
>What's different between them?
Basically nothing. It depends on how your shell handles job control,
if it places background processes in its own session group, and it
stays alive after you log out, some shells dont, and it would have been
killed when you log out.

I suppose you mean 'run as daemon' by placing it in one of the rc scripts ???
Basically the diffrence would be that here it dont have the enviroment variables
you had in your shell, and dont have a controlling terminal, and its
standard in/out/err are probably set to /dev/null

Lawrence Kirby

unread,
Dec 7, 2001, 7:19:00 AM12/7/01
to

These questions have nothing to do with the C language. Please remove
comp.lang.c from followups.

--
-----------------------------------------
Lawrence Kirby | fr...@genesis.demon.co.uk
Wilts, England | 7073...@compuserve.com
-----------------------------------------

Nithyanandham

unread,
Dec 7, 2001, 11:46:19 AM12/7/01
to

Charley wrote:

> Case 1.
> I talk to login shell that execute foo in background and then logout.
> The "foo" runs forever.

Did you nohup the background process?

> Case 2.
> I run the foo as daemon process and logout.
> The daemon "foo" runs forever.
>
> What's different between them?

Background process-its parent is the login shell where it was started,
daemon process - child of process init

Background process-stdin, stdout and stderr are the same as the login
shell, and it is in
the same process group as the login
shell.
daemon process - It has no stdin,stdout or stderr (although it may have a
log file) and it is not in a
process group.

Background process-has controllong tty.
daemon process - No controlling tty.

Normally,
background process- will stop running when you log off.
daemon-will continue running.

> Please explain the concept of daemon in addition.

For more information, you can read 1.7, "Unix Programming FAQ" posted
here and Richard Stevens' UNPv1, chapter 12.


--

Nithyanand.
Siemens, Bangalore, India.
(Opinions expressed are my own and do not reflect the opinions of my
employer, Siemens)

CBFalconer

unread,
Dec 7, 2001, 11:56:16 AM12/7/01
to
Lawrence Kirby wrote:
>
> In article <vY_P7.399$H3.4...@news.bora.net> cha...@serome.co.kr writes:
>
> >Hi.
> >
> >Case 1.
> >I talk to login shell that execute foo in background and then logout.
> >The "foo" runs forever.
> >
> >Case 2.
> >I run the foo as daemon process and logout.
> >The daemon "foo" runs forever.
> >
> >What's different between them?
> >
> >Please explain the concept of daemon in addition.
>
> These questions have nothing to do with the C language. Please remove
> comp.lang.c from followups.

Why not do it yourself? You were there.

--
Chuck F (cbfal...@yahoo.com) (cbfal...@XXXXworldnet.att.net)
Available for consulting/temporary embedded and systems.
(Remove "XXXX" from reply address. yahoo works unmodified)
mailto:u...@ftc.gov (for spambots to harvest)


j...@invalid.address

unread,
Dec 7, 2001, 1:03:49 PM12/7/01
to
Nithyanandham <m.nithy...@blr.spcnl.co.in> writes:

> Charley wrote:
>
> > Case 1.
> > I talk to login shell that execute foo in background and then logout.
> > The "foo" runs forever.
>
> Did you nohup the background process?
>
> > Case 2.
> > I run the foo as daemon process and logout.
> > The daemon "foo" runs forever.
> >
> > What's different between them?
>
> Background process-its parent is the login shell where it was
> started, daemon process - child of process init

Not necessarily started by init though.

> Background process-stdin, stdout and stderr are the same as the
> login shell, and it is in the same process group as the login shell.
> daemon process - It has no stdin,stdout or stderr (although it may

This is a funny way of saying that stdin, stdout and stderr may be
closed, redirected to /dev/null, etc.

> have a log file) and it is not in a process group.

Every process is in some process group.

Lawrence Kirby

unread,
Dec 8, 2001, 8:28:19 AM12/8/01
to
In article <3C10ED2A...@yahoo.com>
cbfal...@worldnet.att.net "CBFalconer" writes:

...

>> These questions have nothing to do with the C language. Please remove
>> comp.lang.c from followups.
>
>Why not do it yourself? You were there.

Because my particular post and likely any discussion resulting from
it was directly relevant to comp.lang.c. However discussion of the
main topic of the thread isn't.

0 new messages