diff options
author | Mikkel Oscar Lyderik <[email protected]> | 2015-12-18 18:02:39 +0100 |
---|---|---|
committer | Mikkel Oscar Lyderik <[email protected]> | 2015-12-18 18:27:54 +0100 |
commit | 90ff36cab8657272b6727af69bab49dba463d6ba (patch) | |
tree | 683793bfcd1cd3a5a53fa27883abde31d71ac09c /sway/config.c | |
parent | ede27eabc53dc926aa1932c2a58c06def1000f86 (diff) |
Terminate children when freeing output container
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/sway/config.c b/sway/config.c index 23fe5388..928d35a8 100644 --- a/sway/config.c +++ b/sway/config.c @@ -389,7 +389,7 @@ static void invoke_swaybar(swayc_t *output, struct bar_config *bar, int output_i list_add(output->bar_pids, pid); } -static void terminate_swaybars(list_t *pids) { +void terminate_swaybars(list_t *pids) { int i, ret; pid_t *pid; for (i = 0; i < pids->length; ++i) { @@ -411,6 +411,16 @@ static void terminate_swaybars(list_t *pids) { } } +void terminate_swaybg(pid_t pid) { + int ret = kill(pid, SIGTERM); + if (ret != 0) { + sway_log(L_ERROR, "Unable to terminate swaybg [pid: %d]", pid); + } else { + int status; + waitpid(pid, &status, 0); + } +} + void load_swaybars(swayc_t *output, int output_idx) { // Check for bars list_t *bars = create_list(); @@ -496,13 +506,7 @@ void apply_output_config(struct output_config *oc, swayc_t *output) { if (oc && oc->background) { if (output->bg_pid != 0) { - int ret = kill(output->bg_pid, SIGTERM); - if (ret != 0) { - sway_log(L_ERROR, "Unable to terminate swaybg [pid: %d]", output->bg_pid); - } else { - int status; - waitpid(output->bg_pid, &status, 0); - } + terminate_swaybg(output->bg_pid); } sway_log(L_DEBUG, "Setting background for output %d to %s", output_i, oc->background); |