From 2a9599ba1bdae5511941c3466ceca8d1b3d74300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 28 Jun 2023 13:38:22 +0800 Subject: [PATCH] move signal --- server.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server.c b/server.c index 7608d2a..d67774a 100644 --- a/server.c +++ b/server.c @@ -87,9 +87,6 @@ static void accept_request(void *cli) { struct stat st; method_type_enum_t method_type; - signal(SIGQUIT, handle_quit); - signal(SIGPIPE, handle_quit); - numchars = get_line(client, buf, sizeof(buf)); j = 0; skiptext(buf, j, numchars - 1); @@ -561,9 +558,11 @@ static void unimplemented(int client) { /************************************************************************/ static pthread_attr_t attr; static int accept_client(int is_unix_sock) { + signal(SIGCHLD, SIG_IGN); + signal(SIGQUIT, handle_quit); + signal(SIGPIPE, handle_quit); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - signal(SIGCHLD, SIG_IGN); while(1) { socklen_t client_name_len = sizeof(client_name); int client_sock = accept(server_sock, (struct sockaddr *)(is_unix_sock?NULL:&client_name), is_unix_sock?NULL:&client_name_len);