[fpc-pascal] respawn a daemon in Linux

Michael Van Canneyt michael at freepascal.org
Tue Jan 14 11:32:18 CET 2014



On Tue, 14 Jan 2014, Mark Morgan Lloyd wrote:

> Michael Schnell wrote:
>> Hi Linux Experts.
>> 
>> Since years I am running an fpc program as a kind of daemon on a PC Linux 
>> server.
>> 
>> I simply defined a "respawn" line in /etc/inittab and with any start of the 
>> server, the program happily automatically runs as a daemon.
>
>> I would appreciate any idea on how to create some kind of "respawn" 
>> algorithm within this program or with a second program - maybe just a 
>> script. In fact I could use "cron" for this, as happily the system does 
>> allow me to edit crontab (which here actually is /etc/config/crontab and 
>> the /etc/config/ is symlinked to a directory residing in a special location 
>> on a hard disk.
>
> Does it exit in a sufficiently-controlled state that you could simply exec a 
> new copy at the end of the finalization block? The available parameters 
> should be accessible in /proc.

No need to modify the program. You can simply script it as

#!/bin/bash
while [ 1 ]; do
   yourprogram youroptions
done

Michael.



More information about the fpc-pascal mailing list