[fpc-pascal] respawn a daemon in Linux

Michael Van Canneyt michael at freepascal.org
Tue Jan 14 11:52:58 CET 2014



On Tue, 14 Jan 2014, Michael Schnell wrote:

> On 01/14/2014 11:32 AM, Michael Van Canneyt wrote:
>> #!/bin/bash
>> while [ 1 ]; do
>>   yourprogram youroptions
>> done
>
> I feel this will start multiple parallel copies of the program and not wait 
> until the previous one dies.

Of course it will wait. 
A script always waits till a command exits.

>
> Moreover I understand that this loop will never exit. Hence I can't use it an 
> init.d script, but in the calling script need to do something based on "bash 
> ... &" to have the "respawn" script run in parallel.

I didn't suggest you'd use this as a init.d script.

In your init.d script you need launch the above script (call it loopmyprogram) 
in the usual manner, in the background.

All this is IMHO preferable to modifying your program, which may introduce 
additional bugs, unforeseen cases etc...

Michael.



More information about the fpc-pascal mailing list