diff --git a/tools/widl/widl.c b/tools/widl/widl.c index e5a772e87bd..79c92e2f338 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -29,6 +29,11 @@ #include #include #include +#include +#include +#ifdef HAVE_SYS_SYSCTL_H +# include +#endif #include "widl.h" #include "utils.h" @@ -562,7 +567,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