Terminate children when freeing output container
This commit is contained in:
parent
ede27eabc5
commit
90ff36cab8
|
@ -185,6 +185,8 @@ int sway_mouse_binding_cmp_buttons(const void *a, const void *b);
|
||||||
void free_sway_mouse_binding(struct sway_mouse_binding *smb);
|
void free_sway_mouse_binding(struct sway_mouse_binding *smb);
|
||||||
|
|
||||||
void load_swaybars(swayc_t *output, int output_idx);
|
void load_swaybars(swayc_t *output, int output_idx);
|
||||||
|
void terminate_swaybars(list_t *pids);
|
||||||
|
void terminate_swaybg(pid_t pid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate and initialize default bar configuration.
|
* Allocate and initialize default bar configuration.
|
||||||
|
|
|
@ -389,7 +389,7 @@ static void invoke_swaybar(swayc_t *output, struct bar_config *bar, int output_i
|
||||||
list_add(output->bar_pids, pid);
|
list_add(output->bar_pids, pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void terminate_swaybars(list_t *pids) {
|
void terminate_swaybars(list_t *pids) {
|
||||||
int i, ret;
|
int i, ret;
|
||||||
pid_t *pid;
|
pid_t *pid;
|
||||||
for (i = 0; i < pids->length; ++i) {
|
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) {
|
void load_swaybars(swayc_t *output, int output_idx) {
|
||||||
// Check for bars
|
// Check for bars
|
||||||
list_t *bars = create_list();
|
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 (oc && oc->background) {
|
||||||
|
|
||||||
if (output->bg_pid != 0) {
|
if (output->bg_pid != 0) {
|
||||||
int ret = kill(output->bg_pid, SIGTERM);
|
terminate_swaybg(output->bg_pid);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sway_log(L_DEBUG, "Setting background for output %d to %s", output_i, oc->background);
|
sway_log(L_DEBUG, "Setting background for output %d to %s", output_i, oc->background);
|
||||||
|
|
|
@ -61,8 +61,12 @@ static void free_swayc(swayc_t *cont) {
|
||||||
free(cont->app_id);
|
free(cont->app_id);
|
||||||
}
|
}
|
||||||
if (cont->bar_pids) {
|
if (cont->bar_pids) {
|
||||||
|
terminate_swaybars(cont->bar_pids);
|
||||||
free_flat_list(cont->bar_pids);
|
free_flat_list(cont->bar_pids);
|
||||||
}
|
}
|
||||||
|
if (cont->bg_pid != 0) {
|
||||||
|
terminate_swaybg(cont->bg_pid);
|
||||||
|
}
|
||||||
free(cont);
|
free(cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue