我正在使用以下设置运行valgrind:
valgrind --tool=memcheck --tool=callgrind --num-callers=20 --track-fds=yes --error-exitcode=1 CMD
。特别是,--track-fds=yes
可以根据需要工作,但每次运行都会因fds 0,1,2而失败,因为它们应该打开。但是,我不想放弃--track-fds
,因为它肯定会提供有意义的信息。那么,是否有一个valgrind选项/方法来跟踪除0,1,2之外的fds?
==5872== FILE DESCRIPTORS: 3 open at exit.
==5872== Open file descriptor 2:
==5872== <inherited from parent>
==5872==
==5872== Open file descriptor 1:
==5872== <inherited from parent>
==5872==
==5872== Open file descriptor 0: /dev/pts/0
==5872== <inherited from parent>
==5872==
==5872==
==5872== Events : Ir
==5872== Collected : 3081079256
==5872==
==5872== I refs: 3,081,079,256
答案 0 :(得分:11)
这些是stdin
,stdout
和stderr
。通常你可以忽略这些,但如果你真的想要挑剔:
fclose(stdin);
fclose(stdout);
fclose(stderr);