adesso funziona perche ho cambiato il processo

This commit is contained in:
Lorenzo Bianchi 2023-06-05 13:11:33 +02:00
parent 5f6986b685
commit 4fa39f47f0
2 changed files with 6 additions and 13 deletions

View File

@ -85,6 +85,7 @@ void rcvPlayer(player_ds *player) {
msgRcv(player, sizeof(player_ds) - sizeof(long), PLAYER);
}
void rcvGame_end(game_end_t *game) {
printf("aspetto game\n");
msgRcv(game, sizeof(game_end_t) - sizeof(long), GAME_END);
}

View File

@ -40,24 +40,14 @@ void sigHandlerServer(int sig) {
// 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);
kill(_PIDS[0], SIGUSR1); //FIXME: fare una funzione per queste robe perche anche gia scritta a fine F4Server
semOp(_SEMID, SERVER, -1);
kill(_PIDS[1], SIGUSR1);
kill(_PIDS[game.winner], SIGUSR1);
// aspetto che i figli ricevano i messaggi
printf("aspettato uno\n");
semOp(_SEMID, SERVER, -1);
printf("aspettato\n");
printf("%d %d\n", _PIDS[0], _PIDS[1]);
kill(_PIDS[0], SIGTERM);
kill(_PIDS[1], SIGTERM);
kill(_PIDS[game.winner], SIGTERM);
raise(SIGTERM);
}
@ -140,6 +130,7 @@ void sigHandlerClient(int sig) {
game_end_t game = {.mtype = GAME_END, .winner = ID ^ 1};
sndGame_end(&game);
kill(SERVER_PID, SIGUSR1);
kill(getpid(), SIGTERM);
}
// Terminazione e chiusura terminale
@ -167,6 +158,7 @@ void sigHandlerClient(int sig) {
game_end_t winner;
rcvGame_end(&winner);
printf("messaggio!\n");
printf("%d %d (%ld)\n", ID, winner.winner, winner.mtype);
// printBoard();
if (winner.winner == ID) {