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

Re: Pipes between lisp and C



Since this reply may be of se to more than the originator of the message,
I am taking the liberty of distributing it to franz-friends.

Communicating over pipes to another process (written in C or any other
languages) is not difficult.  There are two ways of doing it, depending
on which release of Franz Lisp you have.

If you have a vanilla release, you must use the "process" routine.
Its first argument is the name of the program with which you wish to
communicate.  This program is started running.  The other two arguments
are symbols that name the variables where the ports going to and comming
from the process, repectively, are stored.  Note that these variables  must
be declared special since process takes its arguments unevaluated and does
a setq into these variables.

Sometime within the last few months, a few new functions were brought into
Franz that make process communication much cleaner.  The new function
"*process" takes the program's name and two flags.  The optional flags indicate
whether to set up the read and write ports, respectively.  The function
always returns the process id of the child.  If a port is opened, the port
descriptor is returned in a list (see desetq).  Two additional functions,
"*process-send" and "*process-receive" take care of the common cases where you
only write to or read from a process. 

A few warnings apply to any use of pipes in Lisp.  Avoid the function
"resetio", which closes all ports, including the pipes.  Remember to close
pipes when your process dies, or you will soon run out of ports very
quickly.  Call the function "wait" after you close the pipes to kill a
subprocess, otherwise you will have a zombie process lying around.

>From one who has been there,
/Jim