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

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


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

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

wmc: 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>

---

 tools/wmc/wmc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/wmc/wmc.c b/tools/wmc/wmc.c
index 864c969b136..2993d3c5ef7 100644
--- a/tools/wmc/wmc.c
+++ b/tools/wmc/wmc.c
@@ -24,6 +24,11 @@
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
+#include <limits.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_SYSCTL_H
+# include <sys/sysctl.h>
+#endif
 
 #include "wmc.h"
 #include "utils.h"
@@ -165,7 +170,12 @@ static void init_argv0_dir( const char *argv0 )
 #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 path_size = PATH_MAX;
+    char *path = malloc( path_size );
+    if (path && !sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
+        dir = realpath( path, NULL );
+    free( path );
 #else
     dir = realpath( argv0, NULL );
 #endif




More information about the wine-cvs mailing list