[fpc-pascal] simpleipc

Brad Campbell brad at wasp.net.au
Thu Oct 16 11:38:11 CEST 2008


Michael Van Canneyt wrote:
> 
> On Thu, 16 Oct 2008, Brad Campbell wrote:
> 
>> G'day all,
>>
>> I've been having a play with simpleipc.pp for trying to do cross-platform
>> single instance detection.
>>
>> Ordinarily it behaves perfectly, but I just noticed on Linux that it all comes
>> crashing down if the server application crashes without removing the pipe.
>>
>> I then have to manually remove the pipe to be able to start the server again.
>>
>> Has anyone come up against this, or similar previously?
>> I'm somewhat stumped as to how to go about solving this as I can't find a
>> reliable way of detecting a listener on the end of the pipe.
> 
> You could write the server process id to a file, and detect whether the process
> is still alive.

What I ended up doing was creating a lockfile and having the server hold an exclusive lock on it.
If the server starts and can get an exclusive lock then it know's it is the first process running, 
and to delete the ipc pipe if it hangs over from a crash. That is now working perfectly. (Except 
that simpleipc crashes on OSX when it tries to create the fifo, but that's another issue and not 
related to simpleipc).

I'm really quite impressed with simpleipc, it's made going cross platform very easy.

..actually, the whole freepascal/lazarus thing has made going cross platform very easy.

Regards,
Brad
-- 
Dolphins are so intelligent that within a few weeks they can
train Americans to stand at the edge of the pool and throw them
fish.



More information about the fpc-pascal mailing list