reading and writing to another process

RICH.GVT%office-3 at sri-unix.UUCP RICH.GVT%office-3 at sri-unix.UUCP
Fri Sep 30 02:14:00 AEST 1983


In general, you create the pipe, close stdin (or stdout, or stderr), then "dup" 
the appropriate input or output pipe fd which will cause it to reuse the std* 
number you just closed.  You do this for each file you want connected via a 
pipe, then execl the child process.  The parent and child processes can each 
close any unused pipe fd's.

I have an example of exactly this in a program on an off-net computer, and can 
send the actual code later if really needed, but I'd have to read it from one 
terminal and retype it in on another...

You can also specify redirection in the execl command line, using the pipe fd 
number instead of going through the close/dup stuff ( >&4 for instance).  This 
lets you keep the parent's std* connections intact.

Cheers,
Rich <Zellich at OFFICE-3>



More information about the Comp.unix mailing list