Reputation: 13755
I use the following command to run valgrind
. But the ./main
's output will be mixed with the output of valgrind
. I want to keep valgrind
's output to stdout. Is there a way to ignore ./main
's stdout? Thanks.
valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes --callgrind-out-file=/dev/stdout ./main
Upvotes: 2
Views: 645
Reputation: 33747
You can use /proc/$$/fd/1
to refer to the original standard output in the calling shell, before the redirection, like this:
valgrind --tool=callgrind --callgrind-out-file=/proc/$$/fd/1 /bin/echo foo > /dev/null
If the system does not support /proc/$$/fd
but has /dev/fd
(for the current process), this might work (within a script, using bash):
exec {old_stdout}>&1
valgrind --tool=callgrind --callgrind-out-file=/dev/fd/$old_stdout /bin/echo foo > /dev/null
Upvotes: 1