Damjan Jovanovic : server: Use sysctl instead of /proc/curproc/file on FreeBSD.

Alexandre Julliard julliard at winehq.org
Mon Oct 25 16:30:06 CDT 2021


Module: wine
Branch: master
Commit: e224d74a57705ca589b8d6670961d29880eb645a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e224d74a57705ca589b8d6670961d29880eb645a

Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date:   Sat Oct 23 10:14:38 2021 +0200

server: Use sysctl instead of /proc/curproc/file on FreeBSD.

Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 server/unicode.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/server/unicode.c b/server/unicode.c
index 67698d7639c..86a1217b01f 100644
--- a/server/unicode.c
+++ b/server/unicode.c
@@ -25,6 +25,10 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <unistd.h>
+#include <limits.h>
+#ifdef HAVE_SYS_SYSCTL_H
+# include <sys/sysctl.h>
+#endif
 
 #include "windef.h"
 #include "winternl.h"
@@ -240,7 +244,17 @@ static char *get_nls_dir(void)
 #if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
     dir = realpath( "/proc/self/exe", NULL );
 #elif defined (__FreeBSD__) || defined(__DragonFly__)
-    dir = realpath( "/proc/curproc/file", NULL );
+    static int pathname[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
+    size_t dir_size = PATH_MAX;
+    dir = malloc( dir_size );
+    if (dir)
+    {
+        if (sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), dir, &dir_size, NULL, 0 ))
+        {
+            free( dir );
+            dir = NULL;
+        }
+    }
 #else
     dir = realpath( server_argv0, NULL );
 #endif




More information about the wine-cvs mailing list