Lines 40-45
Link Here
|
40 |
#include <sys/socket.h> |
40 |
#include <sys/socket.h> |
41 |
#include <sys/sysctl.h> |
41 |
#include <sys/sysctl.h> |
42 |
#include <sys/user.h> |
42 |
#include <sys/user.h> |
|
|
43 |
#include <sys/sysctl.h> |
43 |
#include <unistd.h> |
44 |
#include <unistd.h> |
44 |
#include <libprocstat.h> |
45 |
#include <libprocstat.h> |
45 |
#else |
46 |
#else |
Lines 275-281
char *os_get_program_data_path_ptr(const char *name)
Link Here
|
275 |
char *os_get_executable_path_ptr(const char *name) |
276 |
char *os_get_executable_path_ptr(const char *name) |
276 |
{ |
277 |
{ |
277 |
char exe[PATH_MAX]; |
278 |
char exe[PATH_MAX]; |
|
|
279 |
#if defined(__FreeBSD__) || defined(__DragonFly__) |
280 |
int sysctlname[4]; |
281 |
size_t pathlen; |
282 |
ssize_t count; |
283 |
|
284 |
sysctlname[0] = CTL_KERN; |
285 |
sysctlname[1] = KERN_PROC; |
286 |
sysctlname[2] = KERN_PROC_PATHNAME; |
287 |
sysctlname[3] = -1; |
288 |
|
289 |
pathlen = PATH_MAX; |
290 |
count = sysctl(sysctlname, nitems(sysctlname), exe, &pathlen, NULL, 0); |
291 |
if (count == -1) { |
292 |
blog(LOG_ERROR, "sysctl(KERN_PROC_PATHNAME) failed, errno %d", errno); |
293 |
return NULL; |
294 |
} |
295 |
count = pathlen; |
296 |
#else |
278 |
ssize_t count = readlink("/proc/self/exe", exe, PATH_MAX); |
297 |
ssize_t count = readlink("/proc/self/exe", exe, PATH_MAX); |
|
|
298 |
#endif |
279 |
const char *path_out = NULL; |
299 |
const char *path_out = NULL; |
280 |
struct dstr path; |
300 |
struct dstr path; |
281 |
|
301 |
|