I'm trying to find the environment variables of a currently running process.
Let the executable be
test. What I'm doing:
./test // first run test
Inside the program I have a print statement doing
getpid() which prints out the current process's pid when the executable starts executing.
Then using the pid printed out to the console, I do,
Now, is there any other way to specify the pid without explicitly writing it out first?
I saw in one of the videos that they specify the pid with a command like this:
seed@ubuntu:~/test$ strings /proc/$$/environ | grep LOGNAME LOGNAME=seed
I didn't understand it quite correctly. Assuming
test as the executable, I tried:
seed@ubuntu: ./test$ strings /proc/\$\$/environ | grep LOGNAME
But it returns:
bash: /test$: No such file or directory
What am I doing wrong?
OS: Seed Ubuntu 16.04 (32 bit) running on Virtual Box GCC Version: 5.4.0