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>.
How to read environment variables value from /proc file system in QNX?
188 views Asked by Arun Nishad At
1
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-- runpidin -p <pid> environmentto dump the environment to the standard output.If you cannot spawn additional processes, what I believe
pidinis doing internally is something like:DCMD_PROC_INFOto retrive the virtual address of the initial stack of the target process;/proc/<pid>/as, seek to the inital stack address, and parse through it:argcargv, so skip past that many char*s, plus one