#include <afblib/service.h>
   typedef void (*session_handler)(int fd, int argc, char** argv);
   void run_service(in_port_t port, session_handler handler,
      int argc, char** argv);


run_service creates a socket with address INADDR_ANY at the given port, and accepts connections. For each accepted connection, a process is spawned that invokes the provided handler which is called with the provided arguments argc and argv. As soon the session handler returns, the spawned off process terminates with an exit code of 0.

run_service terminates only in case of errors. SA_NOCLDWAIT is set for SIGCHLD such that all forked-off processes do not become zombies.


Andreas F. Borchert