I'm running the following code to print info about all processes currently running in the machine:
int i = 0;
var r = "";
var processes = Process.GetProcesses();
foreach (var p in processes)
{
try
{
r += $"{i}. {p.Id} {p.ProcessName} = {p.SessionId}\n";
i++;
}
catch (Exception) { }
}
Console.WriteLine(r);
If I run the built app with admin rights I have access to all process and no exception happens, however SessionId on macOS is always zero:
0. 24976 ProcessNotifier = 0
1. 24970 mdworker_shared = 0
2. 24952 garcon = 0
3. 24951 TextMate = 0
4. 24893 com.apple.iCloudHelper = 0
5. 24770 zsh = 0
...
Is there a way to distinguish between process owners? I want to monitor processes from multiple users.