Last active
May 14, 2020 17:10
-
-
Save kakash1hatake/61129d3186079cc1fc680fa523a1551b to your computer and use it in GitHub Desktop.
set or replace env variable in existing process. requires root privileges
This file contains 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
#!/bin/sh | |
# | |
# set or replace env variable in existing process. requires root privileges | |
# usage: sudo chenv.sh pid var_name var_value | |
# | |
pid=$1 | |
env_name=$2 | |
env_val="$3" | |
out=`gdb -q -batch -ex "attach $pid" -ex 'call (int) setenv("'$env_name'", "'"$env_val"'", 1)' -ex "detach" 2>&1` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment