Fixing the socket handling and add signals to clients. - geomyidae - A small C-based gopherd. HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit dde23cfc01e8301d4263976f711f616f156932f7 DIR parent 8e2c7276d2fa5fd44602707bd0621e0a91646bb8 HTML Author: Christoph Lohmann <20h@r-36.net> Date: Sat, 21 Jul 2012 20:58:29 +0200 Fixing the socket handling and add signals to clients. Diffstat: M handlr.c | 4 ---- M main.c | 9 ++++++++- 2 files changed, 8 insertions(+), 5 deletions(-) --- DIR diff --git a/handlr.c b/handlr.c @@ -163,8 +163,6 @@ handlecgi(int sock, char *file, char *port, char *base, char *args, wait(NULL); if (path != nil) free(path); - shutdown(sock, SHUT_RDWR); - close(sock); break; } } @@ -228,8 +226,6 @@ handledcgi(int sock, char *file, char *port, char *base, char *args, wait(NULL); if (path != nil) free(path); - shutdown(sock, SHUT_RDWR); - close(sock); break; } } DIR diff --git a/main.c b/main.c @@ -421,9 +421,15 @@ main(int argc, char *argv[]) switch(fork()) { case -1: perror("fork"); - close(sock); + shutdown(sock, SHUT_RDWR); break; case 0: + signal(SIGHUP, SIG_DFL); + signal(SIGQUIT, SIG_DFL); + signal(SIGINT, SIG_DFL); + signal(SIGTERM, SIG_DFL); + signal(SIGALRM, SIG_DFL); + handlerequest(sock, base, ohost, sport, clienth, clientp); shutdown(sock, SHUT_RDWR); @@ -432,6 +438,7 @@ main(int argc, char *argv[]) default: break; } + close(sock); } shutdown(listfd, SHUT_RDWR);