Hm, PID trick looks interesting. How linux increments PID? Once created PID is unique for whole user session? I'm mean, is possible situation:
1. Server starting with some PID and write it to known file
2. Client check this PID and if that proces exists, he mark status as connected
3. Server is killed by user.
4. Linux create some proces with PID which previously had server
5. Client check for PID again and see that server still exists (but that is another application)
Is this scenario possible? Can linux assign this same PID (released) for another application?
In the meantime I found temporary solution with "shared memory". I create 1 byte segment with some key and attach server to this segment. Even if I kill server, linux kernell decrement attached applications to this memory segment. Client can get number of attached apps to this segment.
a different approach is making it a TCP/IP server listening on some port.
I considered this way, but I must write one of clients in pure C (to much C headers to translate to FPC) and TCP client is to much tricky for me. I am not familiar in C