... alternatively, here's a simple wrapper around getexecpath(3),
with adjusted test cases to document where we deviate from upstream's
default behavior - might be harder to upstream once 8.0 is released,
but it's worth a shot.
On 9/8/26 7:46 PM, Volker Schlecht wrote:
Here's an attempt to switch libuv to getexecpath(3).
It builds, tests pass, afaict it behaves the same as the other
implementations (i.e. it copies a truncated path and no error
when the path doesn't fit into the buffer).
In lang/node it allows me to drop the current workaround to make
process.execPath work.
It could probably use some adult supervision, though ...
Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/libuv/Makefile,v
retrieving revision 1.34
diff -u -p -r1.34 Makefile
--- Makefile 8 Mar 2026 15:14:43 -0000 1.34
+++ Makefile 8 Sep 2026 18:41:50 -0000
@@ -4,6 +4,7 @@ VER = 1.52.1
DISTNAME = libuv-v${VER}
PKGNAME = libuv-${VER}
CATEGORIES = devel
+REVISION = 0
SHARED_LIBS += uv 5.3 # 1.0
Index: patches/patch-src_unix_openbsd_c
===================================================================
RCS file: patches/patch-src_unix_openbsd_c
diff -N patches/patch-src_unix_openbsd_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_unix_openbsd_c 8 Sep 2026 18:41:50 -0000
@@ -0,0 +1,25 @@
+Index: src/unix/openbsd.c
+--- src/unix/openbsd.c.orig
++++ src/unix/openbsd.c
+@@ -59,15 +59,17 @@ void uv_loadavg(double avg[3]) {
+
+
+ int uv_exepath(char* buffer, size_t* size) {
++
+ if (buffer == NULL || size == NULL || *size == 0)
+ return UV_EINVAL;
+
+- if (uv_saved_argv0 == NULL)
+- return UV_EINVAL;
++ if (getexecpath(buffer, *size) == -1)
++ return UV__ERR(errno);
+
+- return uv__search_path(uv_saved_argv0, buffer, size);
+-}
++ *size = strlen(buffer);
+
++ return 0;
++}
+
+ uint64_t uv_get_free_memory(void) {
+ struct uvmexp info;
Index: patches/patch-test_test-get-currentexe_c
===================================================================
RCS file: patches/patch-test_test-get-currentexe_c
diff -N patches/patch-test_test-get-currentexe_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-test_test-get-currentexe_c 8 Sep 2026 18:41:50 -0000
@@ -0,0 +1,33 @@
+On OpenBSD we expect an error instead of a silently truncated result in
+all cases in which the buffer size is too small to hold the path.
+
+Index: test/test-get-currentexe.c
+--- test/test-get-currentexe.c.orig
++++ test/test-get-currentexe.c
+@@ -75,18 +75,26 @@ TEST_IMPL(get_currentexe) {
+
+ size = 1;
+ r = uv_exepath(buffer, &size);
++#ifndef __OpenBSD__
+ ASSERT_OK(r);
+ ASSERT_OK(size);
+ ASSERT_EQ(buffer[0], '\0');
++#else
++ ASSERT(r);
++#endif
+
+ memset(buffer, -1, sizeof(buffer));
+
+ size = 2;
+ r = uv_exepath(buffer, &size);
++#ifndef __OpenBSD__
+ ASSERT_OK(r);
+ ASSERT_EQ(1, size);
+ ASSERT_NE(buffer[0], '\0');
+ ASSERT_EQ(buffer[1], '\0');
++#else
++ ASSERT(r);
++#endif
+
+ /* Verify uv_exepath is not affected by uv_set_process_title(). */
+ r = uv_set_process_title("foobar");