contrib
debian
docs
i3-config-wizard
i3-dump-log
i3-input
i3-msg
i3-nagbar
i3bar
include
libi3
Makefile
README
fake_configure_notify.c
font.c
get_colorpixel.c
get_mod_mask.c
get_process_filename.c
get_visualtype.c
ipc_connect.c
ipc_recv_message.c
ipc_send_message.c
is_debug_build.c
libi3.mk
root_atom_contents.c
safewrappers.c
string.c
strndup.c
ucs2_conversion.c
man
parser-specs
src
testcases
tests
yajl-fallback
.gitignore
DEPENDS
LICENSE
Makefile
PACKAGE-MAINTAINER
RELEASE-NOTES-4.2
RELEASE-NOTES-4.3
RELEASE-NOTES-4.4
RELEASE-NOTES-4.5
RELEASE-NOTES-4.5.1
common.mk
generate-command-parser.pl
i3-dmenu-desktop
i3-migrate-config-to-v4
i3-sensible-editor
i3-sensible-pager
i3-sensible-terminal
i3.applications.desktop
i3.config
i3.config.keycodes
i3.xsession.desktop
logo.svg
pseudo-doc.doxygen
Without this fix, children of i3bar would inherit the file descriptor of the IPC connection to i3. Therefore, even if i3bar exits with SIGSEGV, the connection to i3 stays open. Because nobody actually reads any messages by i3, the buffer will fill up and i3 can’t deliver any more messages, and thus busy-loops at that point. fixes #995
40 lines
1.0 KiB
C
40 lines
1.0 KiB
C
/*
|
|
* vim:ts=4:sw=4:expandtab
|
|
*
|
|
* i3 - an improved dynamic tiling window manager
|
|
* © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE)
|
|
*
|
|
*/
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/un.h>
|
|
#include <string.h>
|
|
#include <err.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
|
|
#include "libi3.h"
|
|
|
|
/*
|
|
* Connects to the i3 IPC socket and returns the file descriptor for the
|
|
* socket. die()s if anything goes wrong.
|
|
*
|
|
*/
|
|
int ipc_connect(const char *socket_path) {
|
|
int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
|
if (sockfd == -1)
|
|
err(EXIT_FAILURE, "Could not create socket");
|
|
|
|
(void)fcntl(sockfd, F_SETFD, FD_CLOEXEC);
|
|
|
|
struct sockaddr_un addr;
|
|
memset(&addr, 0, sizeof(struct sockaddr_un));
|
|
addr.sun_family = AF_LOCAL;
|
|
strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
|
|
if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0)
|
|
err(EXIT_FAILURE, "Could not connect to i3");
|
|
|
|
return sockfd;
|
|
}
|