# freebsd: use sysctl to get the current executable path · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/9900f94afe5556db048b4b147bbf75ff0e0c9974)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 9900f94afe5556db048b4b147bbf75ff0e0c9974

Requested commit: 9900f94afe5556db048b4b147bbf75ff0e0c9974

Commit: 9900f94afe5556db048b4b147bbf75ff0e0c9974

Tree: 13fa41829db8973d445e8b9ffad9856d2681c8a4

Author: Marcio Giaxa

Committer: Marcio Giaxa

## Message

```
freebsd: use sysctl to get the current executable path

FreeBSD doesn't mount procfs as default on the base system, so we can't
depend on it to get the current path, In this case, we use sysctl(3) to
retrieves the system information and get the same information.

 - CTL_KERN: High kernel limits

 - KERN_PROC: Return selected information about specific running
   processes.

 - KERN_PROC_PATHNAME: The path of the process

 - Process ID: a process ID of -1 implies the current process.

```

## Parents

- [1811e7e6c96844a8381e6a69017948cae0b8b261](https://git.cafe/gitcafe/zig/commit/1811e7e6c96844a8381e6a69017948cae0b8b261?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/9900f94afe5556db048b4b147bbf75ff0e0c9974?format=markdown)
