non funzia piu neanche ctrl c

This commit is contained in:
Lorenzo Bianchi 2023-05-31 12:05:54 +02:00
parent 607acddaf2
commit 5234d5f542
1 changed files with 2 additions and 3 deletions

View File

@ -20,7 +20,6 @@ pid_t _PIDS[2];
void setServerSignal(int sig); void setServerSignal(int sig);
void sigIntHandler2(int sig) { void sigIntHandler2(int sig) {
printf("%d\n", getpid());
exit(0); exit(0);
} }
@ -34,10 +33,9 @@ void sigHandlerServer(int sig) {
if (sig == SIGALRM) { if (sig == SIGALRM) {
printf(PSERVER "Time to exit (%d sec) expired\n", TIME_TO_RESET); printf(PSERVER "Time to exit (%d sec) expired\n", TIME_TO_RESET);
signal(SIGINT, sigIntHandler2); 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 // il giocatore che abbandona mi manda gia il messaggio dicendo che ha vinto l'altro
game_end_t game; game_end_t game;
rcvGame_end(&game); rcvGame_end(&game);
@ -131,6 +129,7 @@ void sigHandlerClient(int sig) {
printf(PCLIENT "Quitting game\n"); printf(PCLIENT "Quitting game\n");
game_end_t game = {.mtype = GAME_END, .winner = ID ^ 1}; game_end_t game = {.mtype = GAME_END, .winner = ID ^ 1};
sndGame_end(&game); sndGame_end(&game);
kill(SERVER_PID, SIGUSR1);
} }
// Terminazione e chiusura terminale // Terminazione e chiusura terminale