Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ static int cbm_powershell_quote_word(const char *value, char *out, size_t out_si
#include <stdlib.h>
#include <string.h> // strtok_r
#include <sys/stat.h> // mode_t, S_IXUSR
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#include <time.h>
#include <wchar.h>
#include <zlib.h> // MAX_WBITS
Expand Down Expand Up @@ -8913,6 +8917,13 @@ static bool cbm_detect_self_path(char *buf, size_t buf_sz, const char *home) {
if (!exact) {
buf[0] = '\0';
}
#elif defined(__FreeBSD__)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
size_t cb = buf_sz;
exact = sysctl(mib, 4, buf, &cb, NULL, 0) == 0 && cb > 0;
if (!exact) {
buf[0] = '\0';
}
#else
ssize_t sp_len = readlink("/proc/self/exe", buf, buf_sz - SKIP_ONE);
exact = sp_len > 0 && (size_t)sp_len < buf_sz - SKIP_ONE;
Expand Down
Loading