Commit Diff


commit - df8f3c74df070ba509ff32f9882258cc557ae928
commit + ac1b786b6855906e4b3e996850f3b42beef1c754
blob - da249ad2fd297fb2c4f96a7521f79a0892249fba
blob + 6a34d1dc82899ce3e316f4a4f708d351cf7d9115
--- thingsd/thingsd.c	
+++ thingsd/thingsd.c	
@@ -187,11 +187,24 @@ main(int argc, char *argv[])
 void
 thgsd_shutdown()
 {
+	pid_t		 pid;
+	int		 status;
+
 	/* close pipe */
 	msgbuf_write(&iev_thgs->ibuf.w);
 	msgbuf_clear(&iev_thgs->ibuf.w);
 	close(iev_thgs->ibuf.fd);
 	free(iev_thgs);
+	log_debug("waiting for children to terminate");
+	do {
+		pid = wait(&status);
+		if (pid == -1) {
+			if (errno != EINTR && errno != ECHILD)
+				fatal("wait");
+		} else if (WIFSIGNALED(status))
+			log_warnx("%s terminated; signal %d", "things",
+			    WTERMSIG(status));
+	} while (pid != -1 || (pid == -1 && errno == EINTR));
 	log_info("%s terminated", getprogname());
 	exit(0);
 }