]> git.sur5r.net Git - i3/i3/commitdiff
i3bar: kill child processes when exit()ing (they might be stopped) (Thanks darkraven)
authorMichael Stapelberg <michael@stapelberg.de>
Mon, 26 Mar 2012 15:36:00 +0000 (17:36 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 26 Mar 2012 15:36:00 +0000 (17:36 +0200)
i3bar/include/child.h
i3bar/src/child.c

index ceb183362bc0c37d93b24523661f1e2f2e3c0b2b..24c7e4600a2878e97974861b6a84b4db2a65884e 100644 (file)
 void start_child(char *command);
 
 /*
- * kill()s the child-prozess (if existend) and closes and
+ * kill()s the child-process (if any). Called when exit()ing.
+ *
+ */
+void kill_child_at_exit();
+
+/*
+ * kill()s the child-process (if any) and closes and
  * free()s the stdin- and sigchild-watchers
  *
  */
index d5efa2aadc470303ff324a852135a19564fca4e0..c97f583800fa0a2f68431c289612332a22c632c8 100644 (file)
@@ -311,6 +311,18 @@ void start_child(char *command) {
     ev_child_init(child_sig, &child_sig_cb, child_pid, 0);
     ev_child_start(main_loop, child_sig);
 
+    atexit(kill_child_at_exit);
+}
+
+/*
+ * kill()s the child-process (if any). Called when exit()ing.
+ *
+ */
+void kill_child_at_exit() {
+    if (child_pid != 0) {
+        kill(child_pid, SIGCONT);
+        kill(child_pid, SIGTERM);
+    }
 }
 
 /*