Recent

Author Topic: SimpleIPCServer crashing on OSX  (Read 1727 times)

Josh

  • Hero Member
  • *****
  • Posts: 1273
SimpleIPCServer crashing on OSX
« on: February 18, 2019, 02:46:59 pm »
Hi
I have a strange problem.
I have a application that can receive instruction from console app, this works well in windows 32/64bit.

On mac, when I run the 'server' app crashes with : raised exception class :'EInOutError\x10' with message Invalid File Handle.

I have traced the error to IPCSErver.Message procedure.

The Code I have that read the message in a timer is
Code: Pascal  [Select][+][-]
  1. if ((my_ipcserver_running=true) and (My_IPCServer.Active) and (My_App_Started)) then
  2. begin
  3.   If  My_IPCServer.PeekMessage(2,false) then
  4.   begin
  5.      My_IPCServer.ReadMessage;   <-- This is what fires the error.
  6.   end;
  7. end;
  8.  

I am wondering if the IPCServer is usig temp files for messages; if it is; is it likely that you will not be able to run from within a bundle.

Has anyone else had a similar problem.

Josh
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: SimpleIPCServer crashing on OSX
« Reply #1 on: February 18, 2019, 07:37:32 pm »
It uses a file (a FIFO named pipe), but it's created in the temp dir. From {fpc_source}/packages/fcl-process/src/unix/simpleipc.inc

Code: Pascal  [Select][+][-]
  1. constructor TPipeServerComm.Create(AOWner: TSimpleIPCServer);
  2. begin
  3.   inherited Create(AOWner);
  4.   FFileName:=Owner.ServerID;
  5.   If Not Owner.Global then
  6.     FFileName:=FFileName+'-'+IntToStr(fpGetPID);
  7.   if FFileName[1]<>'/' then
  8.     FFileName:=GetTempDir(Owner.Global)+FFileName;
  9. end;
  10.  
  11. procedure TPipeServerComm.StartServer;
  12.  
  13. const
  14.   PrivateRights = S_IRUSR or S_IWUSR;
  15.   GlobalRights  = PrivateRights or S_IRGRP or S_IWGRP or S_IROTH or S_IWOTH;
  16.   Rights : Array [Boolean] of Integer = (PrivateRights,GlobalRights);  
  17.    
  18. begin
  19.   If not FileExists(FFileName) then
  20.     If (fpmkFifo(FFileName,438)<>0) then
  21.       DoError(SErrFailedToCreatePipe,[FFileName]);
  22.   FStream:=TFileStream.Create(FFileName,fmOpenReadWrite+fmShareDenyNone,Rights[Owner.Global]);
  23. end;

I don't how that translates to MacOS, though.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Josh

  • Hero Member
  • *****
  • Posts: 1273
Re: SimpleIPCServer crashing on OSX
« Reply #2 on: February 19, 2019, 05:35:10 pm »
Hi

Thanks for your reply.

I restarted my mac, re-build lazarus and all seems to be working now.

Not sure which one fixed it, I suspect re-sarting the mac though, as other apps seems more responsive.

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

 

TinyPortal © 2005-2018