git-2.22.0/exec-cmd.c
/*
 * Resolves the executable path using KERN_PROC_PATHNAME BSD sysctl.
 *
 * Returns 0 on success, -1 on failure.
 */
Resolves the executable path using KERN_PROC_PATHNAME BSD sysctl.
Returns 0 on success, -1 on failure.
Resolves the executable path using KERN_PROC_PATHNAME BSD sysctl . Returns 0 on success - 1 on failure .
static int git_get_exec_path_bsd_sysctl(struct strbuf *buf)
{
	int mib[4];
	char path[MAXPATHLEN];
	size_t cb = sizeof(path);
	mib[0] = CTL_KERN;
	mib[1] = KERN_PROC;
	mib[2] = KERN_PROC_PATHNAME;
	mib[3] = -1;
	if (!sysctl(mib, 4, path, &cb, NULL, 0)) {
		trace_printf(
			"trace: resolved executable path from sysctl: %s\n",
			path);
		strbuf_addstr(buf, path);
		return 0;
	}
	return -1;
}
static int git_get_exec_path_bsd_sysctl ( struct strbuf * buf ) { int mib [ 4 ] ; char path [ MAXPATHLEN ] ; size_t cb = sizeof ( path ) ; mib [ 0 ] = CTL_KERN ; mib [ 1 ] = KERN_PROC ; mib [ 2 ] = KERN_PROC_PATHNAME ; mib [ 3 ] = -1 ; if ( ! sysctl ( mib , 4 , path , & cb , NULL , 0 ) ) { trace_printf ( " \n " , path ) ; strbuf_addstr ( buf , path ) ; return 0 ; } return -1 ; }
Resolves the executable path using KERN_PROC_PATHNAME BSD sysctl.
Resolves the executable path using KERN_PROC_PATHNAME BSD sysctl .