mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 01:34:56 +00:00
Merge pull request #1327 from brauner/2016-11-26/make_lxc_monitord_async_signal_safe
lxc_monitord: make lxc-monitord async signal safe
This commit is contained in:
commit
1e0a00460a
@ -31,6 +31,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <setjmp.h>
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -48,6 +49,8 @@
|
|||||||
|
|
||||||
lxc_log_define(lxc_monitord, lxc);
|
lxc_log_define(lxc_monitord, lxc);
|
||||||
|
|
||||||
|
sigjmp_buf mark;
|
||||||
|
|
||||||
static void lxc_monitord_cleanup(void);
|
static void lxc_monitord_cleanup(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -336,9 +339,7 @@ static void lxc_monitord_cleanup(void)
|
|||||||
|
|
||||||
static void lxc_monitord_sig_handler(int sig)
|
static void lxc_monitord_sig_handler(int sig)
|
||||||
{
|
{
|
||||||
INFO("Caught signal %d.", sig);
|
siglongjmp(mark, 1);
|
||||||
lxc_monitord_cleanup();
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -384,6 +385,9 @@ int main(int argc, char *argv[])
|
|||||||
signal(SIGBUS, lxc_monitord_sig_handler);
|
signal(SIGBUS, lxc_monitord_sig_handler);
|
||||||
signal(SIGTERM, lxc_monitord_sig_handler);
|
signal(SIGTERM, lxc_monitord_sig_handler);
|
||||||
|
|
||||||
|
if (sigsetjmp(mark, 1) != 0)
|
||||||
|
goto on_signal;
|
||||||
|
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
memset(&mon, 0, sizeof(mon));
|
memset(&mon, 0, sizeof(mon));
|
||||||
mon.lxcpath = lxcpath;
|
mon.lxcpath = lxcpath;
|
||||||
@ -427,4 +431,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
exit(ret);
|
exit(ret);
|
||||||
|
|
||||||
|
on_signal:
|
||||||
|
lxc_monitord_cleanup();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user