diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-06 18:34:38 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-06 18:34:38 -0700 |
commit | 38890204ed1f5f8dd34cced7c42fc9cf42dccab5 (patch) | |
tree | 0b6d76adc047a0c81c9e0caf0dbbae93c5461948 /tests/sockets/test_sockets_partial_server.c | |
parent | b5b49215d4a40566380a769f47a9c1cce74a28b0 (diff) | |
parent | fce749a7066e51d57967889fab0600c285885b4b (diff) |
Merge branch 'incoming'
Diffstat (limited to 'tests/sockets/test_sockets_partial_server.c')
-rw-r--r-- | tests/sockets/test_sockets_partial_server.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/sockets/test_sockets_partial_server.c b/tests/sockets/test_sockets_partial_server.c index 44ad40a3..19f7f2af 100644 --- a/tests/sockets/test_sockets_partial_server.c +++ b/tests/sockets/test_sockets_partial_server.c @@ -1,6 +1,7 @@ #include <assert.h> #include <errno.h> #include <fcntl.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -18,8 +19,14 @@ int serverfd = 0; int clientfd = 0; void cleanup() { - if (serverfd) close(serverfd); - if (clientfd) close(clientfd); + if (serverfd) { + close(serverfd); + serverfd = 0; + } + if (clientfd) { + close(clientfd); + clientfd = 0; + } } void do_send(int sockfd) { @@ -86,7 +93,7 @@ int main() { int res; atexit(cleanup); - //signal(SIGTERM, cleanup); + signal(SIGTERM, cleanup); // create the socket serverfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); |