[fpc-pascal] simpleipc

Brad Campbell brad at wasp.net.au
Thu Oct 16 17:52:00 CEST 2008


Luca Olivetti wrote:
> En/na Brad Campbell ha escrit:
> 
>> 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.
> 
> Well, if you detected that's the first (and only) instance running, then 
> you  don't need the ipc server anymore, do you? (as long as it was used 
> only to detect multiple invocations).

Which it's not. I also use it to open windows in the main instance from extra instances opened.

> There's a component/unit named uniqueinstance/uniqueinstanceraw to do 
> that, but since I had problems with it (the process starting more than 
> once), I modified as you say to use a lockfile.

Which is precisely the component I am using, and precisely the problem I came up against. It works 
brilliantly until your main app crashes or is killed or, or, or.. then it just refuses to work until 
you manually clean up after it.

I also have problems with the component itself causing all sorts of segfaults if it aborts an 
application loading when it detects a previous instance. I worked around it, but it's still ugly in 
parts. If I manage to get it cleaned up and de-uglified I'll submit it back.

> Somehow someone managed to start two copies of the same server, I still 
> don't know how since I cannot reproduce it.

Since I made my modifications I've managed to avoid that nicely.

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