| 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(-)
--- |
| @@ -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;
}
} |
| @@ -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); |