X-Git-Url: https://git.cworth.org/git?p=ttt;a=blobdiff_plain;f=src%2Fttt-socket.c;h=f185d363780af7e5c43cb334f9e7ae42c52a258d;hp=765cab1104d7c568b22758a76e6c7c1a508289c8;hb=5d56d3cd8b4685e905ed604277ac9cb32c876127;hpb=152ea9285ef3804783540d46263a7fc9802bc7db diff --git a/src/ttt-socket.c b/src/ttt-socket.c index 765cab1..f185d36 100644 --- a/src/ttt-socket.c +++ b/src/ttt-socket.c @@ -21,7 +21,7 @@ #include "ttt-socket.h" -#include +#include #include /* Initialize a TCP/IP address structure with the given host and port. @@ -146,11 +146,20 @@ ttt_socket_create_server (const char *host, const char *port) /* Exported: see ttt-socket.h for documentation. */ void -ttt_socket_accept (int listen_socket, ttt_socket_dispatch_func_t dispatch) +ttt_socket_accept (int listen_socket, + ttt_socket_accept_func_t accept, + void *closure) { + pid_t pid; int connected_socket; connected_socket = _wait_for_connection (listen_socket); - (dispatch) (connected_socket); + pid = xfork(); + + if (pid == 0) { + /* Child process. */ + (accept) (closure, connected_socket); + return; + } }