gprof and execl() - is it possible?
- by Chris
Background: I have a game (an old-school-esque MUD) which I've been attempting to profile with gprof. The documentation of gprof (on Linux 2.6) states that
The profiled program must call "exit"(2) or return normally for the profiling information to be saved in the gmon.out file.
Now, if I kill the server with the shutdown command, the application "returns normally" (i.e., main() returns) and I get a gmon.out to analyze. However, it's far more common to reboot the server. The reboot command does the following:
Writes usernames and socket FD numbers to disc.
Makes a call to execl().
The new process looks for the stored data, picks up the FDs, and moves on.
I see the following error on the command line, as the whole process fails:
Profiling timer expired ./program
Question: Is it possible to get a gmon.out file from the execl()-calling process? Perhaps some environmental parameter to execl(), or else perhaps a different, gprof-friendly, system call to achieve the same effect (beginning a new process while preserving file descriptors)?