Boolean WBProcessIsNative(pid_t pid) { int ret = FALSE; size_t sz = sizeof(ret); if (sysctlbyname_with_pid("sysctl.proc_native", pid, &ret, &sz, NULL, 0) == -1) { if (errno == ENOENT) { // sysctl doesn't exist, which means that this version of Mac OS // pre-dates Rosetta, so the application must be native. return TRUE; } return FALSE; } return ret ? TRUE : FALSE; }
static bool IsRosettaProcess( pid_t pid ) { bool result = false; int ret = 0; size_t sz = sizeof(ret); if ( sysctlbyname_with_pid( "sysctl.proc_native", pid, &ret, &sz, NULL, 0 ) != -1 ) { if ( ret == 0 ) result = true; } return ( result ); }