mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 02:15:07 -05:00
util: use sigaction() to set signal handler
This commit is contained in:
30
util.c
30
util.c
@@ -845,11 +845,29 @@ UTI_DecodePasswordFromText(char *key)
|
|||||||
int
|
int
|
||||||
UTI_SetQuitSignalsHandler(void (*handler)(int))
|
UTI_SetQuitSignalsHandler(void (*handler)(int))
|
||||||
{
|
{
|
||||||
signal(SIGINT, handler);
|
struct sigaction sa;
|
||||||
signal(SIGTERM, handler);
|
|
||||||
#if !defined(WINNT)
|
sa.sa_handler = handler;
|
||||||
signal(SIGQUIT, handler);
|
sa.sa_flags = SA_RESTART;
|
||||||
signal(SIGHUP, handler);
|
if (sigemptyset(&sa.sa_mask) < 0)
|
||||||
#endif /* WINNT */
|
return 0;
|
||||||
|
|
||||||
|
#ifdef SIGINT
|
||||||
|
if (sigaction(SIGINT, &sa, NULL) < 0)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTERM
|
||||||
|
if (sigaction(SIGTERM, &sa, NULL) < 0)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
#ifdef SIGQUIT
|
||||||
|
if (sigaction(SIGQUIT, &sa, NULL) < 0)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
#ifdef SIGHUP
|
||||||
|
if (sigaction(SIGHUP, &sa, NULL) < 0)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user