Interprocess Communication (IPC) under OSX

Mark Waddingham mark at livecode.com
Tue Dec 19 13:58:39 EST 2017


On 2017-12-19 19:43, Mark Waddingham via use-livecode wrote:
> On 2017-12-18 20:01, Paul Dupuis via use-livecode wrote:
>> In principle, the same code should work equally great under OSX, but 
>> it
>> does not. And yes, if (and when) I have time, i will track down the 
>> bugs
>> and report them, but at the moment I was hoping for a quick fix where
>> someone else already on the list may have identified the OSX
>> idiosyncrasies and had sample code that worked around them :-)
> 
> Hmmm - I have quite a long memory but it doesn't quite stretch as far
> back as 4.6.4 these days so I can' say what might have changed on the
> process related commands in versions since then.
> 
> I do know that there *were* significant bugs in process communication
> on OS X for quite some time after I started working at LiveCode (well,
> RunRev back then) - which gradually got fixed. I'm pretty sure that
> the most recent versions (certainly since 6.x) should be working
> correctly (- but I can't really say much about versions before then.
> 
> So I suspect the issues might be to do with the 4.6.4 side - rather
> than the version on the other side (presumably 6.7.11?).

Of course, looking through the release notes for 4.6.4 I found this:

--------

Slave process improvements (4.5)

A number of issues with the open process command and the engine itself 
have, up until now,
conspired to make it difficult (if not impossible!) to either run a 
slave process, or use the engine as
slave on all platforms.

These issues have been resolved in this version, thus making it 
straightforward to run another
process and poll for input and output over stdin/stdout.
The typical form for this is along the following lines (this example 
assumes the process being
executed outputs whole lines):

command startSlave pProcess
   open process pProcess for text update
   send “monitorSlave pProcess” to me in 50 millisecs
end startSlave

command monitorSlave pProcess
   repeat forever
     # Loop until there are no more lines to read.
     read from process pProcess for 1 line in 0 millisecs
     if the result is empty then
       # The slave has sent us something, so process it and loop for
       # (potentially) more data.
     else if the result is “timeout” then
       # There is nothing waiting for us, so exit repeat
       exit repeat
     else if the result is “eof” then
       # The slave has terminated, so do any final processing and finish
       # monitoring.
       close process pProcess
       exit monitorSlave
     else
       # Some error has occurred!
       exit monitorSlave
     end if
   end repeat
   send “monitorSlave pProcess” to me in 50 millisecs
end monitorSlave

--------

So, it would seem that the issues I refer to above were fixed in 4.5... 
So either other bugs have crept in, or there is a cross-platform 
difference lurking somewhere between mac/windows...

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list