| 43 | } |
| 44 | |
| 45 | static inline TString FreeBSDGetExecPath() { |
| 46 | int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; |
| 47 | TTempBuf buf; |
| 48 | int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf); |
| 49 | if (r == 0) { |
| 50 | return TString(buf.Data(), buf.Filled() - 1); |
| 51 | } else if (r == ENOTSUP) { // older FreeBSD version |
| 52 | /* |
| 53 | * BSD analogue for /proc/self is /proc/curproc. |
| 54 | * See: |
| 55 | * https://www.freebsd.org/cgi/man.cgi?query=procfs&sektion=5&format=html |
| 56 | */ |
| 57 | TString path("/proc/curproc/file"); |
| 58 | return NFs::ReadLink(path); |
| 59 | } else { |
| 60 | return TString(); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | static inline TString FreeBSDGetArgv0() { |
| 65 | int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, getpid()}; |
no test coverage detected