LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Daemon Processhas already been asked (and possibly answered). (https://www.linuxquestions.org/questions/programming-9/daemon-processhas-already-been-asked-and-possibly-answered-364968/)

alaios 09-19-2005 02:34 PM

Daemon Processhas already been asked (and possibly answered).
 
Hi i am trying to create a daemon process

if (pid<0){
printf("Error creating child process ");
}
if (pid >0){
exit(0);
}
sid=setsid();
if (sid<0){
perror("Problem with the child process");
}


What i know is that i have to fork for a new process ... The new process that now runs in to background.. I also know that the daemon code should be inside a while statement so as to run continiously
while(1){
//do your job
}

I want to know if this code will consume all the cpu or not

rstewart 09-19-2005 05:24 PM

Hi,

No, it will behave like any other process and go through the scheduler.


All times are GMT -5. The time now is 03:20 PM.