ho iniziato i sig ma non va il ctrl+c, manca anche parte client
This commit is contained in:
parent
454203af84
commit
209875cbdd
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"errexit.h": "c"
|
"errexit.h": "c",
|
||||||
|
"structures.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,7 +27,7 @@ void checkClientinput(int argc, char *argv[]);
|
||||||
void sigHandlerClient(int sig) {
|
void sigHandlerClient(int sig) {
|
||||||
// Ctrl+C
|
// Ctrl+C
|
||||||
if (sig == SIGINT) {
|
if (sig == SIGINT) {
|
||||||
//TODO:
|
//TODO: abbandono
|
||||||
|
|
||||||
sig = SIGTERM;
|
sig = SIGTERM;
|
||||||
}
|
}
|
||||||
|
@ -155,6 +155,7 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
// mando mossa al server
|
// mando mossa al server
|
||||||
sndMove(&move);
|
sndMove(&move);
|
||||||
|
printfClient("Waiting for oponent"); //FIXME: solo se la partita non è finita
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -3,10 +3,13 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/msg.h>
|
#include <sys/msg.h>
|
||||||
#include <sys/msg.h>
|
#include <sys/sem.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
|
||||||
#include <custom_sig.h>
|
#include <custom_sig.h>
|
||||||
#include <structures.h>
|
#include <structures.h>
|
||||||
|
#include <nonsodovemetterle.h>
|
||||||
|
#include <errExit.h>
|
||||||
|
|
||||||
static int sigint_count = 2;
|
static int sigint_count = 2;
|
||||||
|
|
||||||
|
@ -14,18 +17,19 @@ void setSignal(int sig);
|
||||||
|
|
||||||
void sigHandlerServer(int sig) {
|
void sigHandlerServer(int sig) {
|
||||||
if (sig == SIGINT) {
|
if (sig == SIGINT) {
|
||||||
sigint_count--;
|
// sigint_count--;
|
||||||
if (sigint_count > 0) {
|
// if (sigint_count > 0) {
|
||||||
printfServer("Press again Ctrl^C to exit ");
|
// printfServer("Press again Ctrl^C to exit ");
|
||||||
printf("(whitin %d sec)\n", TIME_TO_RESET);
|
// printf("(whitin %d sec)\n", TIME_TO_RESET);
|
||||||
alarm(TIME_TO_RESET);
|
// alarm(TIME_TO_RESET);
|
||||||
} else {
|
// } else {
|
||||||
sig = SIGTERM;
|
// sig = SIGTERM;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sig == SIGALRM) {
|
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;
|
sigint_count = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue