Change the way remote commands are executed. Clean up some code.
Interprocess communication using files and unix file locks. Script leavemessage reads lines from stdin. The last line it read before exiting or being killed is the contents of the file. Script receivemessage blocks until nobody has an exclusive lock on the file, then outputs the file contents.