Improve handling of nagbar processes
Other changes in nagbar_exited:
- Remove ERROR from ELOG as it shows up as "ERROR: ERROR:"
- Make sure to reset the PID even when the process did not exit
normally.
- Use ELOG when exitcode != 0
- Remove the not found error: if nagbar is not in $PATH, exec_i3_utility
prints an error as well.
For the record, I also implemented a more complicated approach with a
new watcher data structure:
bd3aaf3a33
While writing the commit message, it occurred to me to compare
watcher->pid with *watcher->data, which fixes the problems mentioned in
that patch.
Fixes #4104
This commit is contained in:
parent
6e087d4a20
commit
78595f1f68
@ -42,3 +42,4 @@ working. Please reach out to us in that case!
|
||||
• build: correctly provide auxiliary functions when needed
|
||||
• build: fix issues with parallel build
|
||||
• set _NET_DESKTOP_VIEWPORT after randr changes
|
||||
• fix a bug with i3-nagbar not starting after it has already started once
|
||||
|
@ -1615,8 +1615,16 @@ void cmd_exit(I3_CMD) {
|
||||
*/
|
||||
void cmd_reload(I3_CMD) {
|
||||
LOG("reloading\n");
|
||||
|
||||
kill_nagbar(config_error_nagbar_pid, false);
|
||||
kill_nagbar(command_error_nagbar_pid, false);
|
||||
/* start_nagbar() will refuse to start a new process if the passed pid is
|
||||
* set. This will happen when our child watcher is triggered by libev when
|
||||
* the loop re-starts. However, config errors might be detected before
|
||||
* that since we will read the config right now with load_configuration.
|
||||
* See #4104. */
|
||||
config_error_nagbar_pid = command_error_nagbar_pid = -1;
|
||||
|
||||
load_configuration(NULL, C_RELOAD);
|
||||
x_set_i3_atoms();
|
||||
/* Send an IPC event just in case the ws names have changed */
|
||||
|
20
src/util.c
20
src/util.c
@ -336,18 +336,20 @@ char *pango_escape_markup(char *input) {
|
||||
static void nagbar_exited(EV_P_ ev_child *watcher, int revents) {
|
||||
ev_child_stop(EV_A_ watcher);
|
||||
|
||||
if (!WIFEXITED(watcher->rstatus)) {
|
||||
ELOG("ERROR: i3-nagbar did not exit normally.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int exitcode = WEXITSTATUS(watcher->rstatus);
|
||||
DLOG("i3-nagbar process exited with status %d\n", exitcode);
|
||||
if (exitcode == 2) {
|
||||
ELOG("ERROR: i3-nagbar could not be found. Is it correctly installed on your system?\n");
|
||||
if (!WIFEXITED(watcher->rstatus)) {
|
||||
ELOG("i3-nagbar (%d) did not exit normally. This is not an error if the config was reloaded while a nagbar was active.\n", watcher->pid);
|
||||
} else if (exitcode != 0) {
|
||||
ELOG("i3-nagbar (%d) process exited with status %d\n", watcher->pid, exitcode);
|
||||
} else {
|
||||
DLOG("i3-nagbar (%d) process exited with status %d\n", watcher->pid, exitcode);
|
||||
}
|
||||
|
||||
*((pid_t *)watcher->data) = -1;
|
||||
pid_t *nagbar_pid = watcher->data;
|
||||
if (*nagbar_pid == watcher->pid) {
|
||||
/* Only reset if the watched nagbar is the active nagbar */
|
||||
*nagbar_pid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user