[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

[LI] Re : daemon....



Hi,
 Sameer (xyz@xxxxxxxxxxx) asked about skeletal daemon code.
 Well, the book (Unix Net. Programming by Stevens) actually does that
quite well. A daemon is actually a program that kind of waits in the
background for some event, processes that event, and goes back to
waiting. You put a process into background by fork()ing and letting
the parent die, like so
if ((pid = fork()) == -1) { perror("First fork"); }
if (pid) exit();
----- The child part starts here in background -----
The child usually has an infinite loop, the examples you see in the
book involve waiting for a connection on a port (accept()), but that's because they are networking daemons, you could wait for anything, like signals, files, ports etc. I think the examples in the book are the best. Give the book another go through.
bye,
vml
Model Engg. College, Cochin


_______________________________________________________
Are you a Techie? Get Your Free Tech Email Address Now!
Many to choose from! Visit http://www.TechEmail.com
--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.