Commit 2c1b8153 authored by Damjan Jovanovic's avatar Damjan Jovanovic Committed by Alexandre Julliard

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

parent c1e83ae9
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <signal.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 "wmc.h"
#include "utils.h" #include "utils.h"
...@@ -165,7 +170,12 @@ static void init_argv0_dir( const char *argv0 ) ...@@ -165,7 +170,12 @@ static void init_argv0_dir( const char *argv0 )
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) #if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
dir = realpath( "/proc/self/exe", NULL ); dir = realpath( "/proc/self/exe", NULL );
#elif defined (__FreeBSD__) || defined(__DragonFly__) #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 #else
dir = realpath( argv0, NULL ); dir = realpath( argv0, NULL );
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment