r-lib / ps

R package to query, list, manipulate system processes
https://ps.r-lib.org/
Other
72 stars 18 forks source link

ps_environ() often has empty result on macOS #121

Open gaborcsardi opened 2 years ago

gaborcsardi commented 2 years ago

The issue is that since Big Sur we cannot get the env vars of another process, most of the time. We can only get them if one of these conditions holds:

From https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/kern/kern_sysctl.c#L1315-L1321

Seems like we can get it from an R process, even in RStudio where the exe of the main process is not the same as for the child process. I am not sure why.

There is not much we can do about this, but we need to document it, and it also affects process tree cleanup, here and in processx as well.