diff --git a/config.mk b/config.mk index 8570938..a8c9e69 100644 --- a/config.mk +++ b/config.mk @@ -20,13 +20,17 @@ FREETYPEINC = /usr/include/freetype2 # OpenBSD (uncomment) #FREETYPEINC = ${X11INC}/freetype2 +# FREEBSD (uncomment) +#EPOLLLIBS= -lepoll-shim +#EPOLLINC = /usr/local/include/libepoll-shim + # yajl YAJLLIBS = -lyajl YAJLINC = /usr/include/yajl # includes and libs -INCS = -I${X11INC} -I${FREETYPEINC} -I${YAJLINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${YAJLLIBS} +INCS = -I${X11INC} -I${FREETYPEINC} -I${YAJLINC} -I${EPOLLINC} +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${YAJLLIBS} ${EPOLLLIBS} # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/dwm-msg.c b/dwm-msg.c index 1971d32..5db448a 100644 --- a/dwm-msg.c +++ b/dwm-msg.c @@ -182,7 +182,7 @@ write_socket(const void *buf, size_t count) } static void -connect_to_socket() +connect_to_socket(void) { struct sockaddr_un addr; @@ -280,7 +280,7 @@ is_signed_int(const char *s) } static void -flush_socket_reply() +flush_socket_reply(void) { IPCMessageType reply_type; uint32_t reply_size; @@ -292,7 +292,7 @@ flush_socket_reply() } static void -print_socket_reply() +print_socket_reply(void) { IPCMessageType reply_type; uint32_t reply_size; @@ -352,7 +352,7 @@ run_command(const char *name, char *args[], int argc) } static int -get_monitors() +get_monitors(void) { send_message(IPC_TYPE_GET_MONITORS, 1, (uint8_t *)""); print_socket_reply(); @@ -360,7 +360,7 @@ get_monitors() } static int -get_tags() +get_tags(void) { send_message(IPC_TYPE_GET_TAGS, 1, (uint8_t *)""); print_socket_reply(); @@ -369,7 +369,7 @@ get_tags() } static int -get_layouts() +get_layouts(void) { send_message(IPC_TYPE_GET_LAYOUTS, 1, (uint8_t *)""); print_socket_reply(); diff --git a/dwm.c b/dwm.c index c90c61a..6364d24 100644 --- a/dwm.c +++ b/dwm.c @@ -1963,7 +1963,7 @@ updatebarpos(Monitor *m) } void -updateclientlist() +updateclientlist(void) { Client *c; Monitor *m; diff --git a/ipc.c b/ipc.c index c404791..273ab1a 100644 --- a/ipc.c +++ b/ipc.c @@ -37,7 +37,26 @@ ipc_create_socket(const char *filename) char *normal_filename; char *parent; const size_t addr_size = sizeof(struct sockaddr_un); - const int sock_type = SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC; + const int sock_type = SOCK_STREAM; + int sockfd = socket(AF_INET, sock_type, 0); + // Set the socket to non-blocking + int flags = fcntl(sockfd, F_GETFL, 0); + if (flags == -1) { + die("fctnl get"); + } + if (fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) == -1) { + die("fcntl set non-blocking"); + } + // Set the socket to close-on-exec + flags = fcntl(sockfd, F_GETFD, 0); + if (flags == -1) { + die("fctnl get"); + } + if (fcntl(sockfd, F_SETFD, flags | FD_CLOEXEC) == -1) { + die("fcntl set close-on-exec"); + } + + normalizepath(filename, &normal_filename); @@ -53,11 +72,11 @@ ipc_create_socket(const char *filename) mkdirp(parent); free(parent); - sockaddr.sun_family = AF_LOCAL; + sockaddr.sun_family = AF_UNIX; strcpy(sockaddr.sun_path, normal_filename); free(normal_filename); - sock_fd = socket(AF_LOCAL, sock_type, 0); + sock_fd = socket(AF_UNIX, sock_type, 0); if (sock_fd == -1) { fputs("Failed to create socket\n", stderr); return -1; @@ -782,7 +801,7 @@ ipc_init(const char *socket_path, const int p_epoll_fd, IPCCommand commands[], } void -ipc_cleanup() +ipc_cleanup(void) { IPCClient *c = ipc_clients; // Free clients and their buffers @@ -810,7 +829,7 @@ ipc_cleanup() } int -ipc_get_sock_fd() +ipc_get_sock_fd(void) { return sock_fd; } @@ -828,7 +847,7 @@ ipc_is_client_registered(int fd) } int -ipc_accept_client() +ipc_accept_client(void) { int fd = -1; diff --git a/ipc.h b/ipc.h index e3b5bba..8b9cf2e 100644 --- a/ipc.h +++ b/ipc.h @@ -98,14 +98,14 @@ int ipc_init(const char *socket_path, const int p_epoll_fd, * Uninitialize the socket and module. Free allocated memory and restore static * variables to their state before ipc_init */ -void ipc_cleanup(); +void ipc_cleanup(void); /** * Get the file descriptor of the IPC socket * * @return int File descriptor of IPC socket, -1 if socket not created. */ -int ipc_get_sock_fd(); +int ipc_get_sock_fd(void); /** * Get address to IPCClient with specified file descriptor @@ -142,7 +142,7 @@ int ipc_drop_client(IPCClient *c); * * @return File descriptor of new client, -1 on error */ -int ipc_accept_client(); +int ipc_accept_client(void); /** * Read an incoming message from an accepted IPC client