Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

valgrind `--track-fds=yes` without fds 0,1,2

Tags:

valgrind

I'm running valgrind with following setup: valgrind --tool=memcheck --tool=callgrind --num-callers=20 --track-fds=yes --error-exitcode=1 CMD. Especially,--track-fds=yes work as desired, but every run fails due to fds 0,1,2 which are supposed to be open. However, I don't want to drop --track-fds, as it certainly gives meaningful information. So, is there a valgrind option / method to track fds excluding 0,1,2?

==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
like image 311
xosp7tom Avatar asked Nov 07 '12 22:11

xosp7tom


People also ask

What is valgrind C++?

valgrind is a tool for finding memory access errors to heap memory (memory that is dynamically allocated with new or malloc) in C and C++ programs. Memory access errors are the most difficult bugs to find and to fix.

Why is valgrind taking so long?

Valgrind basically acts like a virtual machine or virtual execution environment running the program, watching all variables, memory allocations, etc., etc. and therefore will run quite a bit slower than native code.

What does valgrind return?

By default Valgrind's malloc, realloc, etc, return a block whose starting address is 8-byte aligned or 16-byte aligned (the value depends on the platform and matches the platform default). This option allows you to specify a different alignment.


1 Answers

Those are stdin, stdout and stderr. Typically you can ignore these but if you really want to be fastidious:

fclose( stdin );
fclose( stdout );
fclose( stderr );

like image 181
ethrbunny Avatar answered Oct 13 '22 14:10

ethrbunny