LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Help, daemon process failed! (https://www.linuxquestions.org/questions/linux-networking-3/help-daemon-process-failed-78187/)

Joran 08-01-2003 08:43 PM

Help, daemon process failed!
 
I writed a daemon program, using the daemon_init() function, giving by the UNIX Network Programming Vol1[Stevens 1998]. But
it exited after this function was called! And when I debuged it with
gdb, I found it exited normally just in this call. Even did the daemon() system call!
I'm very puzzled. Could someone who give me an explaination for detail?
Thanks a lot!

P.S. My kernel is 2.4.18-14(RH8.0)

Joran 08-02-2003 12:05 AM

And that is the code:
Code:

void daemon_init(/*const char* pname, int facility*/)
{
        int i;
        pid_t pid;

        if ((pid = fork()) != 0)
                exit(0);

        setsid();
       
        signal(SIGHUP, SIG_IGN);

        if ((pid = fork()) != 0)
                exit(0);

        /*daemon_proc = 1;*/

        chdir("/");

        umask(0);

        for (i = 0; i < MAXFD; i++)
                close(i);

        /*open(pname, LOG_PID, facility);*/
}


Joran 08-03-2003 05:35 AM

no cool guy know this? :(

waiting........


All times are GMT -5. The time now is 12:22 AM.