Valgrind 不使用 lackey returning 程序的 return 值
Valgrind not returning program's return value using lackey
假设我有一个像这样的非常简单的 C 程序:
int main(){
return 1;
}
我编译成a.out。如果我运行
valgrind ./a.out
我可以得到一个 return 值 1。但是如果我 运行
valgrind --tool=lackey ./a.out
我得到的 return 值为 0。所以我的问题是,如何在将 valgrind 与 lackey 一起使用时获取程序的 return 值?
lackey 输出一个 (confusing/useless) 'valgrind exit code' 这是
据我在 valgrind 源代码中看到的,它始终等于 0。
在所有 valgrind 工具中,只有走狗在使用这种无用的代码。
然而,'real' 退出状态(即被 shell 看到)是由
默认程序的退出状态:
$ valgrind --tool=lackey a.out
...
==7033== Exit code: 0
$ echo $?
1
对于报告错误的工具(例如 memcheck),您可以更改
如果工具检测到错误,程序的退出代码,使用
选项:
--error-exitcode=<number> exit code to return if errors found [0=disable]
假设我有一个像这样的非常简单的 C 程序:
int main(){
return 1;
}
我编译成a.out。如果我运行
valgrind ./a.out
我可以得到一个 return 值 1。但是如果我 运行
valgrind --tool=lackey ./a.out
我得到的 return 值为 0。所以我的问题是,如何在将 valgrind 与 lackey 一起使用时获取程序的 return 值?
lackey 输出一个 (confusing/useless) 'valgrind exit code' 这是 据我在 valgrind 源代码中看到的,它始终等于 0。 在所有 valgrind 工具中,只有走狗在使用这种无用的代码。
然而,'real' 退出状态(即被 shell 看到)是由 默认程序的退出状态:
$ valgrind --tool=lackey a.out
...
==7033== Exit code: 0
$ echo $?
1
对于报告错误的工具(例如 memcheck),您可以更改 如果工具检测到错误,程序的退出代码,使用 选项:
--error-exitcode=<number> exit code to return if errors found [0=disable]