From d519659ea722cb1953e09f184fa16489770c3293 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 26 Mar 2012 17:36:00 +0200 Subject: [PATCH] i3bar: kill child processes when exit()ing (they might be stopped) (Thanks darkraven) --- i3bar/include/child.h | 8 +++++++- i3bar/src/child.c | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/i3bar/include/child.h b/i3bar/include/child.h index ceb18336..24c7e460 100644 --- a/i3bar/include/child.h +++ b/i3bar/include/child.h @@ -21,7 +21,13 @@ 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 * */ diff --git a/i3bar/src/child.c b/i3bar/src/child.c index d5efa2aa..c97f5838 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -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); + } } /* -- 2.39.5