sium fuanzia

This commit is contained in:
Lorenzo Bianchi 2023-06-01 10:35:49 +02:00
parent d80203e938
commit 4b3c8f0c75
1 changed files with 3 additions and 8 deletions

View File

@ -20,7 +20,7 @@ pid_t _PIDS[2];
void setServerSignal(int sig); void setServerSignal(int sig);
void sigIntHandler2(int sig) { void sigIntHandler2(int sig) {
kill(getpid(), SIGTERM); raise(SIGTERM);
} }
void sigHandlerServer(int sig) { void sigHandlerServer(int sig) {
@ -32,7 +32,7 @@ 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, sigHandlerServer);
} }
// abbandono di un giocatore // abbandono di un giocatore
@ -49,11 +49,8 @@ void sigHandlerServer(int sig) {
kill(_PIDS[1], SIGUSR1); kill(_PIDS[1], SIGUSR1);
printf("adesso vi chiudo\n"); printf("adesso vi chiudo\n");
_PIDS[0] = 0; // FIXME: cosi non li prova a richiudere dopo
_PIDS[1] = 0;
sig = SIGTERM; raise(SIGTERM);
} }
if (sig == SIGTERM || sig == SIGHUP) { if (sig == SIGTERM || sig == SIGHUP) {
@ -161,8 +158,6 @@ void sigHandlerClient(int sig) {
} else { } else {
printf("YOU LOST!!!\n"); printf("YOU LOST!!!\n");
} }
exit(0);
} }
} }