3 Jan 2003
(updated 3 Jan 2003 at 00:46 UTC) »
I spent a couple of hours today working on a new daemon mode for prtunnel. There's one daemon process that listens for new connections; when a connection is made, it forks a child process to handle the connection and the daemon process goes back to listening.
The only trouble I had was with waiting for the daemon's children after they're done. The first working solution I had was to make the bound socket non-blocking, put the accept(2) call in a loop, and, when no connection is returned, do a waitpid(2) and usleep a bit inside the loop. That was just too bad of a hack. The current solution is to use a SIGCHLD handler to waitpid(2) and have the accept(2) call loop when it's interrupted. This seems to work OK and will probably be in the next release.
That's it for tonight as far as coding goes. Happy new year, everyone!