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
You want to use
sigaction(2) to define a handler to be run when
SIGTERM is caught.