[fpc-pascal] Stopping daemon in linux

Joost van der Sluis joost at cnoc.nl
Mon Nov 9 14:10:55 CET 2009


On Mon, 2009-11-09 at 13:02 +0200, Wimpie Nortje wrote:
> 
> Michael Van Canneyt wrote:
> > It should stop the daemons properly. This is the code that gets executed:
> >
> > Procedure DoShutDown(Sig : Longint; Info : PSigInfo; Context : 
> > PSigContext);
> > cdecl;
> >
> > begin
> >   Application.StopDaemons(True);
> >   Application.Terminate;
> > end;
> >
> > If it doesn't, something is wrong :(
> I think something is wrong. :(
> 
> For my TDaemon descendant I assigned the following events:
> OnDestroy
> OnExecute
> OnPause
> OnShutdown
> OnStart
> OnStop
> 
> When I type "./daemon -r &"
> The following handlers are executed:
> 1. OnStart
> 2. OnExecute
> 
> When I type "kill -TERM daemon_pid"
> The following handler is executed
> 1. OnDestroy
> 
> I am also a bit confused by the wiki. According to the wiki Start and 
> stop are triggered under linux but shutdown is not. The 'Taming the 
> daemon' article does not specify which of these 3 are called under linux.
> 
> As I mentioned earlier, I use FPC 2.2.4. Could that be the problem?

I don't know how I did it exactly, but I ahve this working properly in a
production system. (Even created my own SysV init script for it. It
should be generally usable for all fpc-daemon applications)

But I did use fpc 2.3.1, so try the new 2.4.0rc1. And I think that it
won't work always now I've read Jonas' mail about it. Maybe I'll look at
that later.

Joost.




More information about the fpc-pascal mailing list