How to get in script whether valgrind found memory leaks? How to get in script whether valgrind found memory leaks? linux linux

How to get in script whether valgrind found memory leaks?


You seem to be looking for the --error-exitcode option.

Since it defaults to 0, the return code from Valgrind is the same as that of the process. Set it to a non-zero value instead.

From Valgrind core manual:

--error-exitcode=<number> [default: 0]

Specifies an alternative exit code to return if Valgrind reported any errors in the run. When set to the default value (zero), the return value from Valgrind will always be the return value of the process being simulated. When set to a nonzero value, that value is returned instead, if Valgrind detects any errors. This is useful for using Valgrind as part of an automated test suite, since it makes it easy to detect test cases for which Valgrind has reported errors, just by inspecting return codes.