int n = read(sockfd, msg + read_bytes, to_read);
if (n == -1)
err(EXIT_FAILURE, "read() failed");
+ if (n == 0)
+ errx(EXIT_FAILURE, "received EOF instead of reply");
read_bytes += n;
to_read -= n;
*/
void ipc_send_event(const char *event, uint32_t message_type, const char *payload);
+/**
+ * Calls shutdown() on each socket and closes it. This function to be called
+ * when exiting or restarting only!
+ *
+ */
+void ipc_shutdown();
#endif
#include "log.h"
#include "sighandler.h"
#include "manage.h"
+#include "ipc.h"
bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction) {
/* If this container is empty, we’re done */
if (STARTS_WITH(command, "exit")) {
LOG("User issued exit-command, exiting without error.\n");
restore_geometry(global_conn);
+ ipc_shutdown();
exit(EXIT_SUCCESS);
}
}
}
+/*
+ * Calls shutdown() on each socket and closes it. This function to be called
+ * when exiting or restarting only!
+ *
+ */
+void ipc_shutdown() {
+ ipc_client *current;
+ TAILQ_FOREACH(current, &all_clients, clients) {
+ shutdown(current->fd, SHUT_RDWR);
+ close(current->fd);
+ }
+}
+
/*
* Executes the command and returns whether it could be successfully parsed
* or not (at the moment, always returns true).
#include "ewmh.h"
#include "manage.h"
#include "workspace.h"
+#include "ipc.h"
static iconv_t conversion_descriptor = 0;
struct keyvalue_table_head by_parent = TAILQ_HEAD_INITIALIZER(by_parent);
void i3_restart() {
restore_geometry(global_conn);
+ ipc_shutdown();
+
LOG("restarting \"%s\"...\n", start_argv[0]);
/* make sure -a is in the argument list or append it */
start_argv = append_argument(start_argv, "-a");