Make restart
IPC command send a reply once restart completed (!) (#3743)
This is achieved by retaining the IPC connection which is sending the restart command across the restart. This is the cleaner fix for https://github.com/i3/go-i3/issues/3 fixes #3565
This commit is contained in:
committed by
GitHub
parent
1eabe1b2b1
commit
e4ecc6e4a1
25
src/main.c
25
src/main.c
@@ -166,7 +166,7 @@ static void i3_exit(void) {
|
||||
fflush(stderr);
|
||||
shm_unlink(shmlogname);
|
||||
}
|
||||
ipc_shutdown(SHUTDOWN_REASON_EXIT);
|
||||
ipc_shutdown(SHUTDOWN_REASON_EXIT, -1);
|
||||
unlink(config.ipc_socket_path);
|
||||
xcb_disconnect(conn);
|
||||
|
||||
@@ -236,6 +236,20 @@ static void setup_term_handlers(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static int parse_restart_fd(void) {
|
||||
const char *restart_fd = getenv("_I3_RESTART_FD");
|
||||
if (restart_fd == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
long int fd = -1;
|
||||
if (!parse_long(restart_fd, &fd, 10)) {
|
||||
ELOG("Malformed _I3_RESTART_FD \"%s\"\n", restart_fd);
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/* Keep a symbol pointing to the I3_VERSION string constant so that we have
|
||||
* it in gdb backtraces. */
|
||||
@@ -847,6 +861,15 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const int restart_fd = parse_restart_fd();
|
||||
if (restart_fd != -1) {
|
||||
DLOG("serving restart fd %d", restart_fd);
|
||||
ipc_client *client = ipc_new_client_on_fd(main_loop, restart_fd);
|
||||
ipc_confirm_restart(client);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */
|
||||
x_set_i3_atoms();
|
||||
ewmh_update_workarea();
|
||||
|
Reference in New Issue
Block a user