2 * vim:ts=4:sw=4:expandtab
4 * i3 - an improved dynamic tiling window manager
6 * © 2009-2011 Michael Stapelberg and contributors
8 * See file LICENSE for license information.
11 #include <sys/types.h>
12 #include <sys/socket.h>
19 * Connects to the i3 IPC socket and returns the file descriptor for the
20 * socket. die()s if anything goes wrong.
23 int ipc_connect(const char *socket_path) {
24 int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
26 err(EXIT_FAILURE, "Could not create socket");
28 struct sockaddr_un addr;
29 memset(&addr, 0, sizeof(struct sockaddr_un));
30 addr.sun_family = AF_LOCAL;
31 strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
32 if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0)
33 err(EXIT_FAILURE, "Could not connect to i3");