diff options
Diffstat (limited to 'app/v3_c/src/main.c')
-rw-r--r-- | app/v3_c/src/main.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/app/v3_c/src/main.c b/app/v3_c/src/main.c index c88485e..d952730 100644 --- a/app/v3_c/src/main.c +++ b/app/v3_c/src/main.c @@ -1,9 +1,32 @@ +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> + +#include "usi2011jjl.h" +#include "utils.h" #include "tcpserver.h" -#define USI2011JJL_VERSION_MAJOR @USI2011JJL_VERSION_MAJOR@ -#define USI2011JJL_VERSION_MINOR @USI2011JJL_VERSION_MINOR@ +extern int end; + +void _signals(int signum) { + static int force=0; + if (0) printf("signal %i\n", signum); + + if(!force) { + end=1; + force=1; + logs("Tentative d'arrêt soft du serveur..."); + } else { + logs("Arrêt d'urgence du serveur"); + exit(1); + } +} int main() { + // On active la gestion des signaux + signal(2,_signals); + + // On exécute le serveur TCP return tcpserver(); } |