« configure | Main | Strata, Diablo... »

August 11, 2005

samba issues -- continued

My work always have problems when programs are being shut down.
To handle them I used some ugly hacks that I hate to describe.

In the source code of smbd, it will register exit_server to be called at exit time (in order to do some clean up work and reclaim children). If running in interactive mode, it will handle the request by itself and then call exit_server. exit_server will do different work based on it's called the first time or not. If running in daemon mode, smbd will not call exit_server directly, but forks a child and then exit. The child then call select and block. After receiving a request, it handles the request, fork a child and then call exit_server.

In order to prevent exit_server from being registered, you need to undef the macro HAVE_ATEXIT, or simply comment out the block from server.c

For such kind of programs like smbd and ghttpd, we have to disable the SIGCHILD (or SIGCLD, A synonym for SIGCHLD) signal handler. It really sucks.

Posted by Roy at August 11, 2005 10:45 PM

Comments