Uncleanly exiting from C child process without valgrind complaining?

Viewed 53

I have a C program which consists on one main process.

Occasionally fork() is used to create a parallel child process. These exist for just a few seconds.

My main process exits nicely, unallocating all its malloc()'ed memory.

I want the child processes to die without unallocating all of their (parent's) malloc()'ed memory, as I have no clean way for them to do this.

However, Valgrind complains loudly every time a child process exit(0)s.

I'm using the command:

valgrind --leak-check=yes --leak-check=full --show-leak-kinds=all --trace-children=no ./my_program

I've tried --trace-children=no. (It should be the default, but Valgrind always traces child processes.)

Is there something I can do in code, or with switches, to make Valgrind not run on child processes?

1 Answers

It turns out that --trace-children=no only applies to fork()s that are followed by exec().

What I needed was: --child-silent-after-fork=yes.

Related