I am new to linux and writing a service in C++ which spawns multiple threads and I am starting the service by calling it from init.d, but how should I send the terminate signal to my application from the script , so that my service terminates all the threads and exits.

And also where can I find the source code for any linux services. e.g. /etc.init.d/rc5.d/S14cron . It will be helpful in understanding how to implement a service.