asl icon indicating copy to clipboard operation
asl copied to clipboard

Get the current process data like in Process class for subprocesses

Open kabukunz opened this issue 4 years ago • 3 comments

Actually it seems we can start a subprocess with Process class; but is there a way to get the current process data? I'd like to read its env vars and get the running process name... Thank you

kabukunz avatar Apr 20 '21 09:04 kabukunz

Current functionality allows reading/writing the subprocess' stdout/stderr/stdin as it runs. The process name is the name of the executable you run, isn't it? And reading its environment variables. Not sure if that is even possible on Windows. I'll check the docs and add that if it is possible. A subprocess inherits the parent process env vars. If it sets new env vars it could communicate them to the parent via stdout or somewhere else. I'll see if that can be "spied" from the parent.

aslze avatar Apr 20 '21 10:04 aslze

On Linux you can read some process's environment vars from /proc/<PID>/environ. But I can't find similar functionality on the Windows API. Do you know a way?

aslze avatar Apr 21 '21 19:04 aslze

Stackoverflow points to a way using some command line trick:

https://superuser.com/questions/415360/how-do-i-find-out-command-line-arguments-of-a-running-program

while it seems the canonical way is by using win openprocess thru C:

https://stackoverflow.com/questions/4570174/how-to-get-the-process-name-in-c

But bear with me, I'm no windows expert al all...

kabukunz avatar May 07 '21 10:05 kabukunz