Hi there
I wrote a few TCP/IP Daemons to teach myself about one of the many aspects of Unix that i'm interested in. I wrote my own daemonize function. I sometimes use this and sometimes use the daemon function from GNU libc. In my multi-threaded version of this network daemon i can call the GNU libc daemon function and in the main thread(main function) just do:
So that the threads that handle client requests in this version of the daemon, never return and are not waited for by
pthread_join(). This works fine but when i use my own daemonize code then i sometimes get crazy runaway threads or processes, in the case of doing the equivalent in the multi-process version of this network daemon( if i use my own daemonize function and do not call
wait() from the main process and just do a pause() as in the above example i sometimes get bad results) I was wondering why this is? Should daemonization be done before the networking setup code(socket, bind, listen) or after it?
The code for the daemonize i can post if anyone is interested in this problem. Thank you very much for any advice or comments/suggestions.
regards