Last active
February 22, 2022 15:38
-
-
Save coderofsalvation/e1376e4d2b29607431df to your computer and use it in GitHub Desktop.
updates an environment variable of a running process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# updates an environment variable of a running process (needs sudo) | |
# example: sudo export_pid <variable=value> <pid> | |
export_process(){ | |
script=/tmp/.gdb.$2 | |
echo -e "attach $2\ncall putenv (\"$1\")\ndetach\n" > $script | |
gdb -q -batch -x $script &>/dev/null | |
rm $script | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I attach gdb to the current shell and try to set env variable it remains the same(or doesn't exist):
I've found out that putenv doesn't work, but setenv does:
According to the documentation