diff options
Diffstat (limited to 'x11-wm/swayfx')
-rw-r--r-- | x11-wm/swayfx/Makefile | 12 | ||||
-rw-r--r-- | x11-wm/swayfx/files/extra-patch-wordexp | 49 | ||||
-rw-r--r-- | x11-wm/swayfx/files/patch-common_stringop.c | 53 |
3 files changed, 60 insertions, 54 deletions
diff --git a/x11-wm/swayfx/Makefile b/x11-wm/swayfx/Makefile index 6d9cf7561faa..8e4890d5cdef 100644 --- a/x11-wm/swayfx/Makefile +++ b/x11-wm/swayfx/Makefile @@ -1,5 +1,6 @@ PORTNAME= sway DISTVERSION= 0.5.3 +PORTREVISION= 1 CATEGORIES= x11-wm wayland PKGNAMESUFFIX= ${GH_PROJECT:S/${PORTNAME}//} @@ -53,6 +54,15 @@ SWAYBG_RUN_DEPENDS= swaybg:x11/swaybg X11_USE= XORG=xcb X11_LIB_DEPENDS= libxcb-icccm.so:x11/xcb-util-wm +.include <bsd.port.options.mk> + +# https://github.com/freebsd/freebsd-src/pull/1675 +.if ${OPSYS} == FreeBSD && (${OSVERSION} < 1305503 \ + || ${OSVERSION} >= 1400000 && ${OSVERSION} < 1403505 \ + || ${OSVERSION} >= 1500000 && ${OSVERSION} < 1500052) +EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-wordexp +.endif + post-patch: # Let @sample handle default files under etc/ @${REINPLACE_CMD} -e '/config\.in/{ N; s/@BASENAME@/&.sample/; }' \ @@ -61,7 +71,7 @@ post-patch: @${REINPLACE_CMD} -i .nogit -e 's/git.found()/false/' \ -e '/project_version/s/@0@/${DISTVERSIONFULL}/' \ ${WRKSRC}/meson.build -.if exists(${.CURDIR}/files/patch-common_stringop.c) +.if exists(${.CURDIR}/files/extra-patch-wordexp) # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275328 @${REINPLACE_CMD} -e 's/_POSIX_C_SOURCE=200809L/_XOPEN_SOURCE=700/' \ ${WRKSRC}/meson.build diff --git a/x11-wm/swayfx/files/extra-patch-wordexp b/x11-wm/swayfx/files/extra-patch-wordexp new file mode 100644 index 000000000000..eb1f79f130f5 --- /dev/null +++ b/x11-wm/swayfx/files/extra-patch-wordexp @@ -0,0 +1,49 @@ +https://github.com/swaywm/sway/issues/8673#issuecomment-2818260191 +https://github.com/swaywm/sway/issues/8828#issuecomment-3290045852 + +--- common/stringop.c.orig 2025-04-20 11:31:10 UTC ++++ common/stringop.c +@@ -6,6 +6,8 @@ + #include <string.h> + #include <strings.h> + #include <wordexp.h> ++#include <signal.h> ++#include <sys/wait.h> + #include "list.h" + #include "log.h" + #include "stringop.h" +@@ -319,7 +321,33 @@ bool expand_path(char **path) { + memmove(ptr + 1, ptr, strlen(ptr) + 1); + *ptr = '\\'; + } +- if (wordexp(*path, &p, 0) != 0 || p.we_wordv[0] == NULL) { ++ ++ // FreeBSD wordexp bug workaround: ++ // 1. Reset SIGCHLD handler ++ // 2. Run wordexp ++ // 3. Restore SIGCHLD handler and reap any processes that exited ++ struct sigaction prev_action; ++ struct sigaction new_action = { ++ .sa_flags = SA_RESETHAND, ++ }; ++ if (sigaction(SIGCHLD, &new_action, &prev_action) != 0) { ++ sway_log(SWAY_ERROR, "Restoring sigchild before wordexp failed"); ++ return false; ++ } ++ ++ int res = wordexp(*path, &p, 0); ++ ++ if (sigaction(SIGCHLD, &prev_action, NULL) != 0) { ++ sway_log(SWAY_ERROR, "Restoring sigchild after wordexp failed"); ++ } ++ ++ int status; ++ int wres; ++ do { ++ wres = waitpid(-1, &status, WNOHANG); ++ } while (wres > 0 || (wres == -1 && errno == EINTR)); ++ ++ if (res != 0 || p.we_wordv[0] == NULL) { + wordfree(&p); + return false; + } diff --git a/x11-wm/swayfx/files/patch-common_stringop.c b/x11-wm/swayfx/files/patch-common_stringop.c deleted file mode 100644 index 5a9f187e11df..000000000000 --- a/x11-wm/swayfx/files/patch-common_stringop.c +++ /dev/null @@ -1,53 +0,0 @@ -https://github.com/swaywm/sway/issues/8673#issuecomment-2818260191 - ---- common/stringop.c.orig 2025-04-20 11:31:10 UTC -+++ common/stringop.c -@@ -6,6 +6,8 @@ - #include <string.h> - #include <strings.h> - #include <wordexp.h> -+#include <signal.h> -+#include <sys/wait.h> - #include "list.h" - #include "log.h" - #include "stringop.h" -@@ -318,11 +320,34 @@ bool expand_path(char **path) { - char *ptr = strstr(*path, " ") + 1; - memmove(ptr + 1, ptr, strlen(ptr) + 1); - *ptr = '\\'; -- } -- if (wordexp(*path, &p, 0) != 0 || p.we_wordv[0] == NULL) { -- wordfree(&p); -- return false; -- } -+ } -+ -+ // FreeBSD wordexp bug workaround: -+ // 1. Reset SIGCHLD handler -+ // 2. Run wordexp -+ // 3. Restore SIGCHLD handler and reap any processes that exited -+ struct sigaction prev_action; -+ struct sigaction new_action = { -+ .sa_flags = SA_RESETHAND, -+ }; -+ if (sigaction(SIGCHLD, &new_action, &prev_action) != 0) { -+ sway_log(SWAY_ERROR, "Restoring sigchild before wordexp failed"); -+ return false; -+ } -+ -+ int res = wordexp(*path, &p, 0); -+ -+ if (sigaction(SIGCHLD, &prev_action, NULL) != 0) { -+ sway_log(SWAY_ERROR, "Restoring sigchild after wordexp failed"); -+ } -+ -+ int status; -+ while (waitpid(-1, &status, WNOHANG) != -1 || errno == EINTR); -+ -+ if (res != 0 || p.we_wordv[0] == NULL) { -+ wordfree(&p); -+ return false; -+ } - free(*path); - *path = join_args(p.we_wordv, p.we_wordc); - wordfree(&p); |