summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--daemon.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/daemon.c b/daemon.c
index cf7f805..59215f6 100644
--- a/daemon.c
+++ b/daemon.c
@@ -321,6 +321,31 @@ int main(int argc, char *argv[]) {
 	sigset_t mask;
 	sigemptyset(&mask);
 	for (;;) {
+		if (signals[SIGCHLD]) {
+			int status;
+			pid_t pid;
+			while (0 < (pid = waitpid(-1, &status, WNOHANG))) {
+				serviceReap(pid, status);
+			}
+			if (pid < 0 && errno != ECHILD) syslog(LOG_WARNING, "waitpid: %m");
+			setTitle();
+			signals[SIGCHLD] = 0;
+		}
+
+		if (signals[SIGINT] || signals[SIGTERM]) {
+			break;
+		}
+		if (signals[SIGHUP]) {
+			parseConfig(configPath);
+			setTitle();
+			signals[SIGHUP] = 0;
+		}
+		if (signals[SIGINFO]) {
+			char command[] = "status *";
+			parseControl(command);
+			signals[SIGINFO] = 0;
+		}
+
 		struct pollfd fds[1 + 2 * services.len];
 		fds[0].fd = fifo;
 		fds[0].events = POLLIN;
@@ -393,31 +418,6 @@ int main(int argc, char *argv[]) {
 			}
 			setTitle();
 		}
-
-		if (signals[SIGCHLD]) {
-			int status;
-			pid_t pid;
-			while (0 < (pid = waitpid(-1, &status, WNOHANG))) {
-				serviceReap(pid, status);
-			}
-			if (pid < 0 && errno != ECHILD) syslog(LOG_WARNING, "waitpid: %m");
-			setTitle();
-			signals[SIGCHLD] = 0;
-		}
-
-		if (signals[SIGINT] || signals[SIGTERM]) {
-			break;
-		}
-		if (signals[SIGHUP]) {
-			parseConfig(configPath);
-			setTitle();
-			signals[SIGHUP] = 0;
-		}
-		if (signals[SIGINFO]) {
-			char command[] = "status *";
-			parseControl(command);
-			signals[SIGINFO] = 0;
-		}
 	}
 
 	close(fifo);