Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will the valgrind work for Daemon programs

Running valgrind on foreground programs is easy. But will valgrind work for daemon programs and give the output after it executes. And how do I do that? Thanks

like image 865
Akshaa Avatar asked Sep 26 '12 05:09

Akshaa


People also ask

Is Valgrind Linux only?

Note: Valgrind is Linux only. If you aren't running Linux, or want a tool designed from the start to make debugging segfaults and memory issues easier, check out Cee Studio, a fully online C and C++ development environment from our sponsor.

Is Valgrind a dynamic library?

Valgrind uses dynamic binary instrumentation, so you don't need to modify, recompile or relink your applications. Just prefix your command line with valgrind and everything works.

Why is valgrind useful?

Valgrind (/ˈvælɡrɪnd/) is a programming tool for memory debugging, memory leak detection, and profiling. Valgrind was originally designed to be a free memory debugging tool for Linux on x86, but has since evolved to become a generic framework for creating dynamic analysis tools such as checkers and profilers.


1 Answers

Yes, valgrind will certainly work for daemon programs.

Many daemons have some sort of debug mode, for example the -X switch to apache, which will cause them not to fork or go into the background, and in that case the easiest way to valgrind them may be by using that mode so that they stay attached to the terminal.

In other cases you will still be able to use valgrind, but you will probably want to use --log-file or one of the other logging options to send the output to a suitable location, and you may also need --trace-children to cause valgrind to follow child processes when the daemon forks.

Output, such as memory leak reports, which is only produced when the program ends, should appear as normal when the daemon is shutdown.

like image 153
TomH Avatar answered Sep 23 '22 03:09

TomH