Skip to content

ps_environ() often has empty result on macOS #121

@gaborcsardi

Description

@gaborcsardi

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:

  • kernel is DEVELOPMENT || DEBUG
  • target process is same as current_proc()
  • target process is not cs_restricted
  • SIP is off
  • caller has an entitlement

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions