Using named pipes lazarus / 32-Linux ---------------------------------------------------------------------- JPT · 2014-11-26 13:13 Hi, I try to exchange messages between two programs via named pipes. Doesn't work, because they wait forever on opening the pipes even if there is no other program active. Or crash when another app tries to access the pipes (e.g. cat) Code: [Select]program testserver; {$MODE Delphi} uses Classes,SysUtils,Crt; var   output: TFileStream;   input: TFileStream;   buffer: String[255];   size: integer;   ctr: integer; begin   output := TFileStream.Create('input.pipe',  fmOpenWrite or fmShareDenyWrite);   input  := TFileStream.Create('output.pipe', fmOpenRead or  fmShareDenyRead);     try     buffer:='';     ctr:=0;     while not keypressed do begin       size:= input.read(buffer[1], 1);       if (size > 0) then begin         writeln('Request: ', buffer, InttoHex(byte(buffer[1]),2));            if buffer[1] = '#128' then begin // data requested           inc(ctr);           buffer:= IntToStr(ctr) + '.0'#13#10;         end;         writeln('Answer: ', buffer);              output.write(buffer[1], length(buffer));       end;       sleep(200);     end;   finally     output.free;     input.free;   end; end. Background: I have to port an old DOS based app that reads measurements from serial port. The hardware is still in production, so I don't have access to it. As you can see, this program is emulating the hardware. the other program looks quite the same, except the file names are opposite and it is requesting data. I added the fmShareDeny... constants but this did not help. any idea? thanks, Jan ---------------------------------------------------------------------- JPT · 2014-11-26 13:18 Changed to mode OBJFPC this changed the behavior: Start A, opens input, waits on output. Start B, opens input, waits on output, crashs A Start A, opens input, waits on output, crashs B An unhandled exception occurred at $08065ECF : EFOpenError : Unable to open file "output.pipe" $08065ECF $08048166 ---------------------------------------------------------------------- marcov · 2014-11-26 13:51 I don't see any pipes in your examples. You try to open two different normal files "input.pipe" and "output.pipe", and do something with totally unrelated function crt.keypressed!?!?!? ---------------------------------------------------------------------- JPT · 2014-11-26 14:00 I created the files using mkfifo. I can remove the keypressed and use while true... I don't think this will change anything. I already tried AssignPipe and FOpen but it seems they both do something completely different.