aaaa perche non funzia

This commit is contained in:
Lorenzo Bianchi 2023-05-21 17:59:02 +02:00
parent c2d47cf457
commit 131702d682
1 changed files with 17 additions and 11 deletions

View File

@ -15,6 +15,10 @@ static int sigint_count = 2;
void setSignal(int sig);
void siginthandler2(int sig) {
kill(getpid(), SIGTERM);
}
void sigHandlerServer(int sig) {
// if (sig == SIGINT) { //FIXME: non riesco a farlo funzionare, quando premo ctr+c è come se gli arrivasse al server la mossa di un giocatore
// sigint_count--;
@ -27,23 +31,25 @@ void sigHandlerServer(int sig) {
// sig = SIGTERM;
// }
// }
if (sig == SIGINT) {
sigint_count--;
if (!sigint_count) {
kill(getpid(), SIGTERM);
}
getchar();
printf("est\n");
sigint_count = 2;
// if (sig == SIGALRM) {
// printfServer("");
// printf("Time to exit (%d sec) expired", TIME_TO_RESET);
// sigint_count = 2;
// }
if (sig == SIGINT) {
printf("\nentarto\n");
signal(SIGINT, siginthandler2);
alarm(3);
}
if (sig == SIGALRM) {
printfServer("");
printf("Time to exit (%d sec) expired", TIME_TO_RESET);
sigint_count = 2;
printf("Resetting handler\n");
signal(SIGINT, sigHandlerServer);
}
if (sig == SIGTERM || sig == SIGHUP) {
if (pids[0] > 0) {
printfServer("Terminating player one");