39 static volatile sig_atomic_t sigflag = 0;
44 static void SignalHandlerSigusr1 (
int signo)
54 static void TellWaitingParent (pid_t pid)
64 static void WaitForChild (pid_t pid)
67 SCLogDebug(
"Daemon: Parent waiting for child to be ready...");
69 while (sigflag == 0) {
70 if (waitpid(pid, &status, WNOHANG)) {
72 if (WIFEXITED(status) || WIFSIGNALED(status)) {
85 static void SetupLogging (
void)
88 int fd = open(
"/dev/null", O_RDWR);
106 signal(SIGUSR1, SignalHandlerSigusr1);
113 #if defined(OS_DARWIN) && defined(__clang__)
114 #pragma clang diagnostic push
115 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
118 #if defined(OS_DARWIN) && defined(__clang__)
119 #pragma clang diagnostic pop
125 }
else if (pid == 0) {
127 const char *daemondir;
134 if (
ConfGet(
"daemon-directory", &daemondir) == 1) {
135 if ((chdir(daemondir)) < 0) {
137 "Error changing to working directory");
142 if (chdir(
"/") < 0) {
151 TellWaitingParent(getppid());
158 SCLogDebug(
"Parent is waiting for child to be ready");