fix improper SIGTERM handling, improve freeing resources
This commit is contained in:
parent
5e3891a985
commit
131ea70b6a
14
yasnd.c
14
yasnd.c
@ -325,6 +325,11 @@ void signal_handler(int signum)
|
||||
{
|
||||
void free_resources()
|
||||
{
|
||||
// lock Main Loop
|
||||
loop_locked=true;
|
||||
// kill Main Loop clone process
|
||||
kill(mainloop_clone_pid,SIGTERM);
|
||||
waitpid(mainloop_clone_pid,NULL,__WCLONE);
|
||||
// Stop IPC loop and remove IPC queue
|
||||
ipc_free();
|
||||
// free config structure
|
||||
@ -341,11 +346,6 @@ void signal_handler(int signum)
|
||||
if (signum==SIGHUP)
|
||||
{
|
||||
log_event("SIGHUP captured, daemon re-read config");
|
||||
// lock Main Loop
|
||||
loop_locked=true;
|
||||
// kill Main Loop clone process
|
||||
kill(mainloop_clone_pid,SIGTERM);
|
||||
waitpid(mainloop_clone_pid,NULL,__WCLONE);
|
||||
// free all resources
|
||||
free_resources();
|
||||
// Init IPC loop again
|
||||
@ -360,12 +360,12 @@ void signal_handler(int signum)
|
||||
if (signum==SIGTERM)
|
||||
{
|
||||
log_event("SIGTERM captured, daemon stopping");
|
||||
// free resources
|
||||
free_resources();
|
||||
// block LPT control circuit
|
||||
lpt_lock();
|
||||
// close log decriptor
|
||||
closelog();
|
||||
// free resources
|
||||
free_resources();
|
||||
//
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user