A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2002-09-14 11:17 AM

From: Dalian ,CHINA
Registered: 2002-08-15
Posts: 6

Re: daemon and no daemon

can anyone tell me the difference in memory and threads between daemon   and no daemon?   when we use daemon to run our multi-thread program, the memory and other sources look normal, but when we use no daemon just to test our program,  memory use, thread number will keep higher and higher some times . 
in fact , i can't describe our program in detail, for it is a little complex, but it is used to monitor a intranet's servers , using threads and sockets and some child processes.   is there any rough description ?



#2 2002-09-30 06:00 PM

From: Sol 3
Registered: 2002-06-12
Posts: 911

Re: daemon and no daemon

This is a guess and would only apply to systems that actually implement threads as "special" processes (such as Linux)... though I do note you said the program is forking children... and the children are in turn multi-threaded (did I read that correctly?)...

If your  program is running as a daemon then it is owned by the core process (init) on the system ...  and that is probably doing all of your cleanup etc. automatically... since it is technically the parent for you program... on the other hand, if you are not running as a daemon then your program is explicitly responsible for cleaning up after itself (using wait( ) or waitpid( ) calls or similar mechanisms) ...

Anyway, I would try (for the non-daemon version) installing a signal handler (for the sigchld signal) in the parent and doing wait / waitpid calls for cleanup... and see if that solves the problem...


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)


Board footer

Powered by FluxBB