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

查看:19
本文介绍了有没有办法改变 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

这是一个非常讨厌的 hack,当然只能在调试场景的上下文中完成.

This is quite a nasty hack and should only be done in the context of a debugging scenario, of course.

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

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