I have a program that only generates the output when it returns normally or when it calls the exit() function (I'm trying to use gcov on a C program). On a special input my program hangs in an infinite loop so I have to terminate it by sending termination signal. In this situation it won't produce the output I need since it wouldn't call exit().
Is there any way that I can force a running program to call exit() and terminate without touching the source code and writing a signal handler?