Re: daemon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 15, 2001 at 01:12:59AM +0900, Jonathan Khoo wrote:

[I don't know if questions about the userland libraries is on-topic for
this list or not. I'm sure riel will clue-bat me if I shouldn't have
responded to this email. :]

> I have a question about the function daemon. In my program, I used
> "daemon(0,0);"
> But the program seems to exit right after the function is called. I
> couldn't find the program when I do a ps -aux | grep

In my copy of Stevens's Advanced Programming in the Unix Environment, he
builds a daemon() function that uses fork() and kills the 'parent', to
help dissasociate the process from the terminal.[1] I don't know the
glibc daemon(3) implementation, but it might do something similar.
Depending upon what you are grepping for in your 'ps aux' output (say,
the pid you *think* it is), you might miss it entirely. :)

Try just looking through 'ps aux' output manually, without grep, to see
if you can find your process... :)

Cheers!

[1]: Stevens also mentions that some people prefer *two* fork()/exit()
pairs, to kill off two sets of parents, to prevent inheriting ttys on
open() as a controlling terminal, on SysV. (Since that book is now
officially 'old'[2], maybe it ought to be amended to say 'on POSIX'
rather than 'on SysV'. :)

[2]: The only mention of Linux in the whole book is on the back cover,
in a book review written by someone at Linux Journal... 4.4BSD hadn't
been released when it was written. Yeah, it is a bit of an old book. :)

-- 
The Bill of Rights: 7 out of 10 rights haven't been sold yet! Contact
your congressman for details how *you* can buy one today!

PGP signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux