[Lazarus] Linux service

Patrick Chevalley pch at ap-i.net
Wed Nov 27 13:14:39 CET 2013


To enable your program to react to signal you need to use fpSigAction. 
See here for usage: http://www.freepascal.org/docs-html/rtl/baseunix/fpsigaction.html

Instead of SigUsr1 in the example you can register a procedure for SIGTerm to handle a termination request.
You can also add a procedure for SIGHUP if you want to implement a "service .. reload" action.
The complete list of signal is in rtl/linux/signal.inc

By using SIGTerm (the default kill signal) you can cleanly close your program and releasing all resources, this is much better than using "kill -9" that stop the program abruptly. 


More information about the Lazarus mailing list