mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-28 22:23:42 +01:00
Make sway/ipc-server.c POSIX 2001 compliant
This commit replaces the non-standard SOCK_NONBLOCK and SOCK_CLOEXEC flags with two fcntl calls. This makes the file POSIX 2001 compliant, thus it is no longer necessary to conditionally define, or use internal (__BSD_VISIBLE) feature test macros.
This commit is contained in:
parent
3e924f2345
commit
2f258eff6f
1 changed files with 8 additions and 5 deletions
|
@ -1,8 +1,5 @@
|
||||||
// See https://i3wm.org/docs/ipc.html for protocol information
|
// See https://i3wm.org/docs/ipc.html for protocol information
|
||||||
#ifndef __FreeBSD__
|
#define _POSIX_C_SOURCE 200112L
|
||||||
// Any value will hide SOCK_CLOEXEC on FreeBSD (__BSD_VISIBLE=0)
|
|
||||||
#define _XOPEN_SOURCE 700
|
|
||||||
#endif
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
#elif __FreeBSD__
|
#elif __FreeBSD__
|
||||||
|
@ -89,10 +86,16 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ipc_init(struct sway_server *server) {
|
void ipc_init(struct sway_server *server) {
|
||||||
ipc_socket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
ipc_socket = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
if (ipc_socket == -1) {
|
if (ipc_socket == -1) {
|
||||||
sway_abort("Unable to create IPC socket");
|
sway_abort("Unable to create IPC socket");
|
||||||
}
|
}
|
||||||
|
if (fcntl(ipc_socket, F_SETFD, FD_CLOEXEC) == -1) {
|
||||||
|
sway_abort("Unable to set CLOEXEC on IPC socket");
|
||||||
|
}
|
||||||
|
if (fcntl(ipc_socket, F_SETFL, O_NONBLOCK) == -1) {
|
||||||
|
sway_abort("Unable to set NONBLOCK on IPC socket");
|
||||||
|
}
|
||||||
|
|
||||||
ipc_sockaddr = ipc_user_sockaddr();
|
ipc_sockaddr = ipc_user_sockaddr();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue