qnxqnx-neutrino

How to read environment variables value from /proc file system in QNX?


I want to read an environment variable value of a running process from /proc file system. I could not find /proc/<pid>/environ file on QNX. I know how we can read it from getenv API but I want to read it from /proc/<pid>.


Solution

  • To the best of my knowledge there's no easy-to-use API on QNX for accessing another program's environment programmatically.

    If your application permits, the easiest solution is to use QNX's pidin -- run pidin -p <pid> environment to dump the environment to the standard output.

    If you cannot spawn additional processes, what I believe pidin is doing internally is something like: