Use the 'signal' system call.
sighandler is the function that should be invoked when ur process recieves the function signal name. but remember to write sighandler without () i.e., don't write it as,
cos signal expects a function pointer. except SIGKILL, all the signals can be caught. read "unix network programming" by richard stevens for details.