How do I tell valgrind to memcheck forked processes?

I have a process x that I want to check for leaks with valgrind. The problem is that x is run by y, and y in turn is run by z. I can't run x standalone because y and z setup the environment for x, such as environment variables, command line switches, files needed by x etc.

  1. Is there any way I can tell valgrind to run on z but to follow any forks it finds and report them too?
  2. Is there any way I can tell valgrind to follow any forks but only report on the process named x?
  3. Is there any way I can tell valgrind to attach to already-running process, the way I can do with gdb?

I don't know if this matters, but I'm running under Suse64 linux and valgrind-2.4.0.



  1. Valgrind follows forked processes when given the --trace-children=yes option.
  2. You should be able to achieve this by using suitable filters.
  3. No. Valgrind hooks into the module loading code using LD_PRELOAD, so attaching to a running process is not possible.

Need Your Help

XpathNavigator raise error NotSupportedException

xpath c#-3.0 xpathnavigator

I want to update XDocument using the following code

Creating checkerboard image for texture

c++ opengl texture-mapping

Please help me understand what the following is doing. Specifically, what is variable 'c', and what is the third array dimension for (isn't an image a 2-dimensional pixel rectangle)?

Foreach implementation in C++, a Poor man's approach


There are happy people working with boost and Qt. In my current "embedded" project I have to use home-made container classes. OK, enough complaining.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.