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 trap and exec?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.
Wrapper program that sets signal handler
bash;signals;system calls;trap
Can't be done. From the exec(3p) man page:Signals  set to be caught by the calling process image shall be set to the         default action in the  new  process  image.You would have to write a preload SO which would hook up the signal handlers before the program started.