From 5234d5f542ff14451ab63368ed216c1883c858ad Mon Sep 17 00:00:00 2001 From: Lorenzo Bianchi Date: Wed, 31 May 2023 12:05:54 +0200 Subject: [PATCH] non funzia piu neanche ctrl c --- src/custom_sig.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/custom_sig.c b/src/custom_sig.c index 7dafb4a..5dcf487 100644 --- a/src/custom_sig.c +++ b/src/custom_sig.c @@ -20,7 +20,6 @@ pid_t _PIDS[2]; void setServerSignal(int sig); void sigIntHandler2(int sig) { - printf("%d\n", getpid()); exit(0); } @@ -34,10 +33,9 @@ void sigHandlerServer(int sig) { if (sig == SIGALRM) { printf(PSERVER "Time to exit (%d sec) expired\n", TIME_TO_RESET); signal(SIGINT, sigIntHandler2); - perror(""); } - if (sig = SIGUSR1) { + if (sig == SIGUSR1) { // il giocatore che abbandona mi manda gia il messaggio dicendo che ha vinto l'altro game_end_t game; rcvGame_end(&game); @@ -131,6 +129,7 @@ void sigHandlerClient(int sig) { printf(PCLIENT "Quitting game\n"); game_end_t game = {.mtype = GAME_END, .winner = ID ^ 1}; sndGame_end(&game); + kill(SERVER_PID, SIGUSR1); } // Terminazione e chiusura terminale