il server non chiude piu

This commit is contained in:
Lorenzo Bianchi 2023-05-31 12:15:20 +02:00
parent 5234d5f542
commit 751dda12b7
2 changed files with 9 additions and 2 deletions

View File

@ -6,4 +6,6 @@
- messaggio speciale per abbandono
- se le ipcs non si sono chiuse bene non funzia
- se le ipcs non si sono chiuse bene non funzia
- fa errore quando un giocatore abbandona

View File

@ -35,10 +35,12 @@ void sigHandlerServer(int sig) {
signal(SIGINT, sigIntHandler2);
}
// abbandono di un giocatore
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);
printf("vince %d\n", game.winner);
sndGame_end(&game);
sndGame_end(&game);
@ -46,7 +48,9 @@ void sigHandlerServer(int sig) {
kill(_PIDS[0], SIGUSR1); //FIXME: fare una funzione per queste robe perche anche gia scritta a fine F4Server
kill(_PIDS[1], SIGUSR1);
_PIDS[0] = 0;
printf("adesso vi chiudo\n");
_PIDS[0] = 0; // FIXME: cosi non li prova a richiudere dopo
_PIDS[1] = 0;
sig = SIGTERM;
@ -129,6 +133,7 @@ void sigHandlerClient(int sig) {
printf(PCLIENT "Quitting game\n");
game_end_t game = {.mtype = GAME_END, .winner = ID ^ 1};
sndGame_end(&game);
printf("server pid: %d\n", SERVER_PID);
kill(SERVER_PID, SIGUSR1);
}