I would like to have a wrapper program that runs a given command and sets a signal handler so that it gets run when the command receives a specified signal.
The question is this:
- Is there an utility program to do this?
- If not, is it possible to do this by using bash's commands
- If not, how can I do this? (e.g. by writing a program myself in C which does a few system calls)
EDIT: The target platform is GNU/Linux.
EDIT 2: Following Ignacio's answer, I managed to write a preload SO which looks like this.