[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

multiple servers (was: Speed of rc)



> Date: Thu, 8 Apr 1993 20:38:11 -0400
> From: Scott Schwartz <schwartz@groucho.cs.psu.edu>
> 
> Just some random thoughts...
> 
> Tom <culliton@srg.af.mil> writes:
> | I actually spent a fair amount of time once trying to figure out a
> | stunt to run co-processes under rc so I can fire up sh (for test), and
> | something else to do math, exactly once and then have functions that
> | talk to them.  In the end I decided it either couldn't be done or
> | wasn't worth the effort.
> 
> Yet another defect in Unix, where IPC is so limited that even simple
> and obvious things are so painful that no one does them.  Similarly, if
> dynamic loading were fundamental and pervasive one could envision
> taking any a.out file, mapping it once, and then calling its entry
> points.  For example, make the system (OS, language runtime, etc)
> understand /bin/sh/glob.  Then the normal execve means calling
> /bin/sh/main.
> 
> The problem with being spartan is that you end up being stoic.

On a simpler level, it appears to me that there is no way to create a
circular pipe in es, but if you could, you could make a server
function fairly easily (excuse the mangled syntax, I'm just
now planning to switch from rc to es):

fn server cmd reader writer {
	%pipe {$cmd} (1 0) (>10 <11) {
		$reader={line >[0=11]}
		$writer=@ args {
			for (i=$args) {
				echo $i >[1=10]}}}}

Then you could say, e.g.:
	server bc bc-answer ask-bc
then:
	ask-bc 3 4 + 2 '*'
	echo `bc-answer
and get:
	14

(In my hacked extension to the %pipe syntax:
	%pipe cmd [list-of-left-side-descriptors
		   list-of-right-side-descriptors-and-directions
		    cmd] ...
lets you connect any number of pipes.  There's got to be a better way.)

You could also write a server for test that ran /bin/sh (you'd have to
send it cd commands as well as test commands so that paths would be
consistent) (although I personally think this would be a horrible hack).

../Dave