mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
define signal handler for a clean shutdown of the proxy
This commit is contained in:
parent
89b431ec8d
commit
695e4e9dc9
1 changed files with 25 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -67,6 +68,11 @@ static void fini_env(void)
|
|||
unlink(fname);
|
||||
}
|
||||
|
||||
static void exit_handler(int sig)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static int init_env(void)
|
||||
{
|
||||
int j, fd;
|
||||
|
@ -75,6 +81,25 @@ static int init_env(void)
|
|||
FILE* file;
|
||||
char isle_path[MAX_PATH];
|
||||
char* result;
|
||||
struct sigaction sINT, sTERM;
|
||||
|
||||
/* define action for SIGINT */
|
||||
sINT.sa_handler = exit_handler;
|
||||
sINT.sa_flags = 0;
|
||||
if (sigaction(SIGINT, &sINT, NULL) < 0)
|
||||
{
|
||||
perror("sigaction");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* define action for SIGTERM */
|
||||
sTERM.sa_handler = exit_handler;
|
||||
sTERM.sa_flags = 0;
|
||||
if (sigaction(SIGTERM, &sTERM, NULL) < 0)
|
||||
{
|
||||
perror("sigaction");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
str = getenv("HERMIT_ISLE");
|
||||
if (str)
|
||||
|
|
Loading…
Add table
Reference in a new issue