* Resolves the executable path using KERN_PROC_PATHNAME BSD sysctl. * * Returns 0 on success, -1 on failure. */
| 109 | * Returns 0 on success, -1 on failure. |
| 110 | */ |
| 111 | static int git_get_exec_path_bsd_sysctl(struct strbuf *buf) |
| 112 | { |
| 113 | int mib[4]; |
| 114 | char path[MAXPATHLEN]; |
| 115 | size_t cb = sizeof(path); |
| 116 | |
| 117 | mib[0] = CTL_KERN; |
| 118 | mib[1] = KERN_PROC; |
| 119 | mib[2] = KERN_PROC_PATHNAME; |
| 120 | mib[3] = -1; |
| 121 | if (!sysctl(mib, 4, path, &cb, NULL, 0)) { |
| 122 | trace_printf( |
| 123 | "trace: resolved executable path from sysctl: %s\n", |
| 124 | path); |
| 125 | strbuf_addstr(buf, path); |
| 126 | return 0; |
| 127 | } |
| 128 | return -1; |
| 129 | } |
| 130 | #endif /* HAVE_BSD_KERN_PROC_SYSCTL */ |
| 131 | |
| 132 | #ifdef HAVE_NS_GET_EXECUTABLE_PATH |
no test coverage detected