commit 990cb6330871e31d2c077bc53b4a348f9656f2a7
parent 6ce0b7782b1786ac9b0ea5c3412a703b512447b1
Author: chld <chld@disroot.org>
Date: Sun, 22 Mar 2026 15:56:01 -0500
fix xwayland ceasing to start in freebsd fix fcntl failing causing xwayland to be ineffective
Diffstat:
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/launch/launch.c b/launch/launch.c
@@ -449,6 +449,10 @@ setup_tty(int fd)
if (ioctl(fd, KDSKBMODE, K_OFF) == -1) {
die("failed to set keyboard mode to K_OFF:");
}
+#elif defined(__FreeBSD__)
+ if (ioctl(fd, KDSKBMODE, K_RAW) == -1) {
+ die("failed to set keyboard mode to K_RAW:");
+ }
#endif
if (ioctl(fd, KDSETMODE, KD_GRAPHICS) == -1) {
perror("KDSETMODE KD_GRAPHICS");
@@ -569,7 +573,14 @@ main(int argc, char *argv[])
usage(argv[0]);
}
- if (socketpair(AF_LOCAL, SOCK_SEQPACKET, 0, sock) == -1) {
+
+ if (socketpair(AF_LOCAL,
+ #ifdef __linux__
+ SOCK_SEQPACKET,
+ #else
+ SOCK_STREAM,
+ #endif
+ 0, sock) == -1) {
die("socketpair:");
}
if (fcntl(sock[0], F_SETFD, FD_CLOEXEC) == -1) {
diff --git a/libswc/xserver.c b/libswc/xserver.c
@@ -155,6 +155,7 @@ begin:
close(lock_fd);
+ #ifdef __linux__
/* Bind to abstract socket */
addr.sun_path[0] = '\0';
snprintf(addr.sun_path + 1, sizeof(addr.sun_path) - 1, SOCKET_FMT,
@@ -162,6 +163,9 @@ begin:
if ((xserver.abstract_fd = open_socket(&addr)) < 0) {
goto retry1;
}
+ #else
+ xserver.abstract_fd=-1;
+ #endif
/* Bind to unix socket */
mkdir(SOCKET_DIR, 0777);
@@ -182,7 +186,9 @@ close_display(void)
{
char path[64];
+ #ifdef __linux__
close(xserver.abstract_fd);
+ #endif
close(xserver.unix_fd);
snprintf(path, sizeof(path), SOCKET_FMT, xserver.display);
@@ -268,6 +274,9 @@ xserver_initialize(void)
/* Unset the FD_CLOEXEC flag on the FDs that will get passed to
* Xwayland. */
for (index = 0; index < ARRAY_LENGTH(fds); ++index) {
+#if defined(__FreeBSD__)
+ if (fds[index]==-1) continue;
+#endif
if (fcntl(fds[index], F_SETFD, 0) != 0) {
ERROR("fcntl() failed: %s\n", strerror(errno));
goto fail;
@@ -290,9 +299,16 @@ xserver_initialize(void)
}
setenv("WAYLAND_SOCKET", strings[0], true);
+
+ #ifdef __linux__
execlp("Xwayland", "Xwayland", xserver.display_name, "-rootless",
"-terminate", "-listen", strings[2], "-listen", strings[3],
"-wm", strings[1], NULL);
+ #else
+ execlp("Xwayland", "Xwayland", xserver.display_name, "-rootless",
+ "-terminate", "-listen", strings[3],
+ "-wm", strings[1], NULL);
+ #endif
fail:
exit(EXIT_FAILURE);