有没有办法在 Unix 中更改另一个进程的环境变量? [英] Is there a way to change the environment variables of another process in Unix?
本文介绍了有没有办法在 Unix 中更改另一个进程的环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Unix 上,有什么办法可以让一个进程改变另一个进程的环境变量(假设它们都由同一个用户运行)?一个通用的解决方案是最好的,但如果不是,那么一个是另一个的孩子的具体情况呢?
On Unix, is there any way that one process can change another's environment variables (assuming they're all being run by the same user)? A general solution would be best, but if not, what about the specific case where one is a child of the other?
通过 gdb 怎么样?
How about via gdb?
推荐答案
通过 gdb:
(gdb) attach process_id
(gdb) call putenv ("env_var_name=env_var_value")
(gdb) detach
这是一个非常讨厌的黑客,当然应该只在调试场景的上下文中完成.
This is quite a nasty hack and should only be done in the context of a debugging scenario, of course.
这篇关于有没有办法在 Unix 中更改另一个进程的环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文