Running stdin/out through a pipe to a child process
Mark Steven Jeghers
mark at cogent.UUCP
Mon Jan 12 17:14:42 AEST 1987
I need to know how I might create a child process with 2 pipes connected to
it, one with which the parent process feeds a stream to the childs stdin,
and one from which the parent reads a stream from the childs stdout. I
understand how to use popen() to connect either stdin OR stdout between
processes, but I need to have BOTH. The following picture demonstrates:
+-------------------+
| |
| Parent Process |
| |
+-------------------+
Pipe that | ^ Pipe that
feeds stdin V | reads stdout
+-------------------+
| |
| Child Process |
| |
| (could be a |
| filter like |
| sed or cat, |
| or a shell) |
| |
+-------------------+
I imagine that I could probably use fork() for this, that is, I could
have all the pipes I wanted between the processes then. But, after getting
the child process to exec() into the program I want there (like sed, cat, or
sh) how would I get those pipes to be hooked up to the child processes stdin
and stdout?
--
+----------------------------------------------------------------------------+
| Mark Steven Jeghers ECHOMPGULP - process has eaten it |
| cryptography, terrorist, DES, drugs, cipher, secret, decode, NSA, CIA, NRO |
| |
| {ihnp4,cbosgd,lll-lcc,lll-crg}|{dual,ptsfa}!cogent!mark |
| |
| Cogent Software Solutions can not be held responsible for anything said |
| by the above person since they have no control over him in the first place |
+----------------------------------------------------------------------------+
More information about the Comp.unix.wizards
mailing list