From 209875cbdd9eee673f74984fefbbea90fc7670cc Mon Sep 17 00:00:00 2001 From: Lorenzo Bianchi Date: Sun, 21 May 2023 12:23:00 +0200 Subject: [PATCH] ho iniziato i sig ma non va il ctrl+c, manca anche parte client --- .vscode/settings.json | 3 ++- src/F4Client.c | 3 ++- src/custom_sig.c | 24 ++++++++++++++---------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 13c1de6..18aa7c8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "files.associations": { - "errexit.h": "c" + "errexit.h": "c", + "structures.h": "c" } } \ No newline at end of file diff --git a/src/F4Client.c b/src/F4Client.c index 5dcdd13..dbb8c52 100644 --- a/src/F4Client.c +++ b/src/F4Client.c @@ -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; diff --git a/src/custom_sig.c b/src/custom_sig.c index 9646814..534fe82 100644 --- a/src/custom_sig.c +++ b/src/custom_sig.c @@ -3,10 +3,13 @@ #include #include #include -#include +#include +#include #include #include +#include +#include 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; }