diff options
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); |