有没有办法改变另一个进程的环境变量? [英] Is there a way to change another process's environment variables?

查看:190
本文介绍了有没有办法改变另一个进程的环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Unix上,有没有办法一个进程可以改变另一个进程的环境变量(假设它们全部由同一个用户运行)?一般的解决方案是最好的,但如果没有,一个人是另一个孩子的具体情况呢?



编辑:通过gdb如何?

解决方案

通过gdb:

  gdb)attach process_id 

(gdb)call putenv(env_var_name = env_var_value)

(gdb)detach

这是一个讨厌的黑客,当然只能在调试场景的上下文中完成。


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?

Edit: How about via gdb?

解决方案

Via 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.

这篇关于有没有办法改变另一个进程的环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆