3

I have a coded a program in C for linux. At the moment I am using ubuntu upstart to run as a background service.

I want to be able to have the program gracefully shutdown when commanded instead of just being killed off. Can someone please point me to the functions used to receive such a command?

(edit: can't answer own post but it seems I am meant to use signal.h signal function to put callbacks on SIGTERM and SIGKILL).

4

1 回答 1

4

You want to use sigaction(2) to define a handler to be run when SIGTERM is caught.

于 2011-06-15T02:01:27.927 回答