Move nagbar cleanup to i3_exit
Otherwise, each time we start a nagbar, a cleanup handler is created. However, each of these handlers tries to kill the same process (->data is a pointer to config_error_nagbar_pid / command_error_nagbar_pid). With this commit, both potential nagbar processes are killed once.
This commit is contained in:
@ -182,6 +182,10 @@ static void i3_exit(void) {
|
||||
unlink(config.ipc_socket_path);
|
||||
xcb_disconnect(conn);
|
||||
|
||||
/* If a nagbar is active, kill it */
|
||||
kill_nagbar(config_error_nagbar_pid, false);
|
||||
kill_nagbar(command_error_nagbar_pid, false);
|
||||
|
||||
/* We need ev >= 4 for the following code. Since it is not *that* important (it
|
||||
* only makes sure that there are no i3-nagbar instances left behind) we still
|
||||
* support old systems with libev 3. */
|
||||
|
20
src/util.c
20
src/util.c
@ -352,19 +352,6 @@ static void nagbar_exited(EV_P_ ev_child *watcher, int revents) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup handler. Will be called when i3 exits. Kills i3-nagbar with signal
|
||||
* SIGKILL (9) to make sure there are no left-over i3-nagbar processes.
|
||||
*
|
||||
*/
|
||||
static void nagbar_cleanup(EV_P_ ev_cleanup *watcher, int revent) {
|
||||
pid_t *nagbar_pid = (pid_t *)watcher->data;
|
||||
if (*nagbar_pid != -1) {
|
||||
LOG("Sending SIGKILL (%d) to i3-nagbar with PID %d\n", SIGKILL, *nagbar_pid);
|
||||
kill(*nagbar_pid, SIGKILL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Starts an i3-nagbar instance with the given parameters. Takes care of
|
||||
* handling SIGCHLD and killing i3-nagbar when i3 exits.
|
||||
@ -397,13 +384,6 @@ void start_nagbar(pid_t *nagbar_pid, char *argv[]) {
|
||||
ev_child_init(child, &nagbar_exited, *nagbar_pid, 0);
|
||||
child->data = nagbar_pid;
|
||||
ev_child_start(main_loop, child);
|
||||
|
||||
/* install a cleanup watcher (will be called when i3 exits and i3-nagbar is
|
||||
* still running) */
|
||||
ev_cleanup *cleanup = smalloc(sizeof(ev_cleanup));
|
||||
ev_cleanup_init(cleanup, nagbar_cleanup);
|
||||
cleanup->data = nagbar_pid;
|
||||
ev_cleanup_start(main_loop, cleanup);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user