Help: pipe accross two processes

Roger Droz roger at gtisqr.uucp
Thu Dec 6 09:58:53 AEST 1990


In article <1510 at ulowell.ulowell.edu> mchetan at hawk.ulowell.edu (Munisuvratha Chetan) writes:
>
>I have two processes - a server and a client.
>The server runs in an infinite loop untill killed.
>After the server is brought up, clients wil be forked, from a
>different shell.  If the clients know the process id of the
>server, how can I establish a communication channel between the
>two using pipes (and signals, if necessary) only.

How about using named pipes. (See mknod(1))

The server can open(2) several named pipes with O_NDELAY set and start
polling.  The clients don't need to know the process id of the server;
just the directory where the set of named pipes can be found.  The
clients can tell when they open a pipe for writing if a reader (the
server) is running.

You will need to come up with some mechanism of lock files to keep two
clients from opening the same pipe.  You will also need two pipes for each
client to accomplish two way communication, but I assume you already know
that.

There are other ways of doing this sort of thing in Unix, but you said
you wanted to use pipes.
____________
               Roger Droz       UUCP: uw-beaver!gtisqr!roger
()       ()    Maverick MICRoSystems / Global Technology International
 (_______)     Mukilteo, WA 
  (     )      
   |   |       Disclaimer: "We're all mavericks here: 
   |   |                    Each of us has our own opinions,
   (___)                    and the company has yet different ones!"



More information about the Comp.unix.questions mailing list