I have a binary build with -fprofile-arcs
and -ftest-coverage
. The binary is run by a process monitor which spawns the process as a child process. Then, when I want the process to exit, I have to go through the process monitor. It sends a SIGKILL
to the process. I found out that .gcda
files do not generate in this case. What can I do?
EDIT: Actually the process monitor first tries to make the process exit. However, the ProcessMonitor library (used in each process) calls _exit
instead of exit
when the user issues a command to stop the process. This is the cause of all trouble.
SIGKILL
is a "hard" kill signal, that cannot be caught by the application. Therefore, the app has no chance to write out the .gcda
file.
I see two options:
SIGKILL
: any sensible process monitor should send a SIGTERM
first. init
and the batch managers I've encountered do this. SIGKILL
is a last resort, so it should be sent only after SIGTERM
followed by a grace period.SIGKILL
; have the actual program check periodically (or in a separate thread) if its parent still lives, and if not, have it exit gracefully.