New function Proc_GenericSignalHandler()
This commit is contained in:
parent
0db9a31e50
commit
4cc4c29e38
|
@ -18,6 +18,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -99,4 +100,19 @@ Proc_Kill(PROC_STAT *proc)
|
||||||
Proc_InitStruct(proc);
|
Proc_InitStruct(proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic signal handler for forked child processes.
|
||||||
|
*/
|
||||||
|
GLOBAL void
|
||||||
|
Proc_GenericSignalHandler(int Signal)
|
||||||
|
{
|
||||||
|
switch(Signal) {
|
||||||
|
case SIGTERM:
|
||||||
|
#ifdef DEBUG
|
||||||
|
Log_Subprocess(LOG_DEBUG, "Child got TERM signal, exiting.");
|
||||||
|
#endif
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -eof- */
|
/* -eof- */
|
||||||
|
|
|
@ -30,6 +30,8 @@ GLOBAL pid_t Proc_Fork PARAMS((PROC_STAT *proc, int *pipefds,
|
||||||
|
|
||||||
GLOBAL void Proc_Kill PARAMS((PROC_STAT *proc));
|
GLOBAL void Proc_Kill PARAMS((PROC_STAT *proc));
|
||||||
|
|
||||||
|
GLOBAL void Proc_GenericSignalHandler PARAMS((int Signal));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -eof- */
|
/* -eof- */
|
||||||
|
|
|
@ -108,29 +108,13 @@ Resolve_Name( PROC_STAT *s, const char *Host, void (*cbfunc)(int, short))
|
||||||
} /* Resolve_Name */
|
} /* Resolve_Name */
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signal handler for the forked resolver subprocess.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
Signal_Handler(int Signal)
|
|
||||||
{
|
|
||||||
switch(Signal) {
|
|
||||||
case SIGTERM:
|
|
||||||
#ifdef DEBUG
|
|
||||||
Log_Subprocess(LOG_DEBUG, "Resolver: Got TERM signal, exiting.");
|
|
||||||
#endif
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize forked resolver subprocess.
|
* Initialize forked resolver subprocess.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
Init_Subprocess(void)
|
Init_Subprocess(void)
|
||||||
{
|
{
|
||||||
signal(SIGTERM, Signal_Handler);
|
signal(SIGTERM, Proc_GenericSignalHandler);
|
||||||
Log_Init_Subprocess("Resolver");
|
Log_Init_Subprocess("Resolver");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue