in reply to SIG{ALRM} to help kill external program

If it were me, I’d follow the suggestion of forking-off the analysis program as a child of a command-process that then goes to sleep waiting for it to end, or to receive a signal.   This controller-program can do nice things like set priorities for the child, divert its output this way or that, set up any peculiar things that the child might need, and even monitor it to see if it is still consuming CPU time.     Upon receipt of the proper signal, the controller program deals the coup de grace to the analysis program, waits to bury it and set up a nice tombstone, and so on.   None of this magick is visible to anyone who just wants “to analyze a file,” but it really works out well.