Thx a lot for your asnwes.. i have some questions concering the code i have found here
http://www.csfalcon.com/index.jsp?topic=UNIX%20Daemon
I have executed your code some times and as i can see the demon procees depends in the child process as u destroy the parent... Are u absolutely sure that this is the best way for implementing this?
Except from these i just want to know
if the following code is necessary
umask(0);
sid = setsid(); /* obtain new process group */
if (sid < 0){
/* error */
}
chdir("/");
/* close input/output of the daemon process */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
Why do u need the umask and do u want to obtain a new process group? And finally why do u close the input/output of the daemon process?
Thx a lot.. have a nice week