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

Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Damjan Jovanovic 2021-10-23 10:15:55 +02:00 committed by Alexandre Julliard
parent f5e51cfc55
commit 70f486c28f

View file

@ -58,6 +58,10 @@
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include <limits.h>
#ifdef HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif
#ifdef __APPLE__
# include <CoreFoundation/CoreFoundation.h>
# define LoadResource MacLoadResource
@ -600,7 +604,14 @@ static void init_paths( char *argv[] )
#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
bin_dir = realpath_dirname( "/proc/self/exe" );
#elif defined (__FreeBSD__) || defined(__DragonFly__)
bin_dir = realpath_dirname( "/proc/curproc/file" );
{
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 ))
bin_dir = realpath_dirname( path );
free( path );
}
#else
bin_dir = realpath_dirname( argv0 );
#endif