Hello.
There is no code here, you’ll find all the bash code you need on the net, by googling bash mkfifo example.
You can try this:
[code]Open two terminal windows, both with the same current directory.
Type cat pipe in the first.
Activate the second window.
Type and execute mkfifo pipe
Type ls-l >pipe and hit enter.
Look into the first window to see that now the result of the ls command has shown up in it.
Go back to the second window and “rm pipe”, we are done with the demonstration![/code]
The idea is to have two applets, that both executes a do shell script in a loop, you can use two pipes, that both has open the way you want, but one must of course write. You’ll use mkpipe for creating a communication-channel in the form of a pipe, not unlike those you create when you combine several shell-commands, but this pipe, has a pathname.
That way, you can have the two applets communicate with each other.
Of course this will make the applets, use more resources, but not that much, and you can write data into the writing side of the pipe, that the other applet will get on the reading side, and process.
I am not sure if this is any better, then sending messages, but at least it is cheaper, when it comes to apple events, and maybe it makes it easier to synchronize two processes. You’ll have to think out something up front, of course, a protocol, and the like, but at least it makes it possible to simulate a multi-threaded app.
The “reading app” doesn’t even have to block extensively while waiting for data, as the read command of bash has a timeout.
Maybe an Idea worth following.
Edit
One thing I haven’t tested is if it is possible to read and write to a pipe directly with Applescripts read and write commands, if this works, then it makes the usag of pipes between apps/scripts even simpler!
And this (the first approach with shell), can of course be used in combination with FSEvents (Launchd Agents), and you get synchron communication between two applets if you use two pipes, one for incoming, one for outgoing.