Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!eru!luth!sunic!lth.se!newsuser From: d89cb@efd.lth.se (Christian Brunschen) Newsgroups: comp.lang.c Subject: Filtering I/O -- both of them. Summary: How can I redirect stdin and stdout to a pipe ? Message-ID: <1990Jul8.120742.18213@lth.se> Date: 8 Jul 90 12:07:42 GMT Sender: newsuser@lth.se (LTH network news server) Reply-To: d89cb@efd.lth.se (Christian Brunschen) Organization: Lund Institute of Technology, Sweden Lines: 38 I'm working an a small program that will function as an i/o filter for mail (1) -- fyi, so tat all occurrences of 'mail' can be replaced with 'femail' (No, not my idea -- I'm doing this for a friend :) Anyway, i could use popen(), but that only lets me specify either stdin or stdout replacement -- not both, the way I need it. So I thought of : * creating two pipes * fork()ing * in the child process, redirect stdin to one pipe & stdout to the other * in the cild process, execve() mail(1) * in the parent process, perform i/o and filtering BUT (and here's my question) : how do I actually redirect stdin / stdout to the pipes I created ? I tried stdin = fdopen (MyPipe [1], "r"); but that, naturally, didn't work (illegal lhs of assignment) So, if anyone has any ideas, please tell me; All help will be greatly appreciated! aTdHvAaNnKcSe -- Christian Brunschen -- +--------------------------------+---------------------------------+ | Internet : d89cb@efd.lth.se | IRC : snooker | +------------------------------------------------------------------+ | Apart from the unknowns, everything is obvious." | | - ZORAC, board computer of the Shapieron, in | | James P. Hogan's "Giants' Star" | +------------------------------------------------------------------+