Add SIGTERM handler
This commit is contained in:
parent
160dbcd50f
commit
b82eff1c72
13
MD_Init.c
13
MD_Init.c
@ -3,6 +3,7 @@
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -172,6 +173,16 @@ int read_doorsys(const char *dropfile) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(WIN32) && !defined(_MSC_VER)
|
||||
|
||||
void md_sigtermhandler(int i)
|
||||
{
|
||||
md_exit(-1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void md_exit(int exitcode) {
|
||||
if (mdcontrol.socket == -1) {
|
||||
#if !defined(WIN32) && !defined(_MSC_VER)
|
||||
@ -187,6 +198,8 @@ void md_init(const char *dropfile, int socket) {
|
||||
char *filename = strrchr(dropfile, PATH_SEP);
|
||||
#if !defined(WIN32) && !defined(_MSC_VER)
|
||||
struct termios ttystate;
|
||||
signal(SIGTERM, &md_sigtermhandler);
|
||||
|
||||
#endif
|
||||
int ret = -1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user