I'm working on porting command-line software used in web development. Is there any way to see if a process is being run under Rosetta 2 from the command line? Anything outside of Activity Monitor?
Check if process is running under Rosetta 2?
What would be your goal in knowing this? Are you planning on doing something different based on running natively vs. Rosetta 2?
https://developer.apple.com/videos/play/wwdc2020/10686/ provides the following code sample:
Code Block // Use "sysctl.proc_translated" to check if running in Rosetta // Returns 1 if running in Rosetta int processIsTranslated() { int ret = 0; size_t size = sizeof(ret); // Call the sysctl and if successful return the result if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) != -1) return ret; // If "sysctl.proc_translated" is not present then must be native if (errno == ENOENT) return 0; return -1; }
You can check in the activity monitor under "Architecture". Intel vs Apple.
Edit: I noticed that you do know about activity monitor route, sorry.
Edit: I noticed that you do know about activity monitor route, sorry.