为什么GDB启动新的外壳,以及如何禁用此行为? [英] Why does GDB start a new shell and how to disable this behaviour?
问题描述
我搞清楚开始从GDB产生一个符号查找错误应用程序的问题,但是从shell工作启动它。
I was figuring out a problem where starting the application from GDB results in a symbol lookup error, but starting it from the shell works.
原来,每当你从GDB启动程序将启动一个新的外壳,从而覆盖我开始GDB之前已设置所有环境变量(如 LD_LIBRARY_PATH
)
It turns out that whenever you start a program from within GDB it will start a new shell and thus override all environment variables I had set before starting GDB (like LD_LIBRARY_PATH
).
这是不是真的我想要的行为。有人可以解释这样做的理由,或者告诉我怎样可以关闭此功能?
This is not really the behavior I want. Can someone explain the rationale behind this, or tell me how I can turn this off?
推荐答案
我猜测你的无条件的设置 LD_LIBRARY_PATH
在〜/ .cshrc中
等。所以,如果从shell提示你这样做:
I am guessing that you unconditionally set LD_LIBRARY_PATH
in your ~/.cshrc
or the like. So if from a shell prompt you do this:
export LD_LIBRARY_PATH=foo # or for csh:
setenv LD_LIBRARY_PATH foo
$SHELL -c 'echo $LD_LIBRARY_PATH'
结果比富
以外的东西。不要做的是的
the result is something other than foo
. Don't do that.
这通常发生在CSH用户,谁忽视了保护自己的〜/ .cshrc中
对非交互shell。它也可能发生在BASH谁设置用户在他们的 BASH_ENV
。
Usually this happens to CSH users, who neglected to protect their ~/.cshrc
against non-interactive shells. It could also happen to BASH users who set their BASH_ENV
.
这篇关于为什么GDB启动新的外壳,以及如何禁用此行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!