ho iniziato i sig ma non va il ctrl+c, manca anche parte client

This commit is contained in:
Lorenzo Bianchi 2023-05-21 12:23:00 +02:00
parent 454203af84
commit 209875cbdd
3 changed files with 18 additions and 12 deletions

View File

@ -1,5 +1,6 @@
{
"files.associations": {
"errexit.h": "c"
"errexit.h": "c",
"structures.h": "c"
}
}

View File

@ -27,7 +27,7 @@ void checkClientinput(int argc, char *argv[]);
void sigHandlerClient(int sig) {
// Ctrl+C
if (sig == SIGINT) {
//TODO:
//TODO: abbandono
sig = SIGTERM;
}
@ -155,6 +155,7 @@ int main(int argc, char *argv[]){
// mando mossa al server
sndMove(&move);
printfClient("Waiting for oponent"); //FIXME: solo se la partita non è finita
}
return 0;

View File

@ -3,10 +3,13 @@
#include <unistd.h>
#include <signal.h>
#include <sys/msg.h>
#include <sys/msg.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <custom_sig.h>
#include <structures.h>
#include <nonsodovemetterle.h>
#include <errExit.h>
static int sigint_count = 2;
@ -14,18 +17,19 @@ void setSignal(int sig);
void sigHandlerServer(int sig) {
if (sig == SIGINT) {
sigint_count--;
if (sigint_count > 0) {
printfServer("Press again Ctrl^C to exit ");
printf("(whitin %d sec)\n", TIME_TO_RESET);
alarm(TIME_TO_RESET);
} else {
sig = SIGTERM;
}
// sigint_count--;
// if (sigint_count > 0) {
// printfServer("Press again Ctrl^C to exit ");
// printf("(whitin %d sec)\n", TIME_TO_RESET);
// alarm(TIME_TO_RESET);
// } else {
// sig = SIGTERM;
// }
}
if (sig == SIGALRM) {
printfServer("Time to exit (%d sec) expired", TIME_TO_RESET);
printfServer("");
printf("Time to exit (%d sec) expired", TIME_TO_RESET);
sigint_count = 2;
}