If a C++ program is called by a python script, how do you get Valgrind to check leaks in the C++ program and not just in the script? For example, if leak.cc contains the following code
int main() {
int* p = new int;
}
and is compiled into a.out, and call_aout.py contains
#!/usr/bin/env python
import subprocess
subprocess.call(["./a.out"])
then running valgrind via
valgrind --track-origins=yes --leak-check=full -v ./call_aout.py
will not detect the memory leak in leak.cc, but calling it via
valgrind --track-origins=yes --leak-check=full -v ./a.out
will detect it.
valgrindtrack new, forked processes, too?valgrindalways follows forks, but he needs it to follow anexec