Redirecting STDOUT using spawn

Peter da Silva peter at ficc.uu.net
Sat Feb 24 10:43:59 AEST 1990


>         freopen("FILE", "w", stdout);
>         ercode = spawnlp(P_WAIT, "PROG.EXE", "PROG", "ARGS", NULL);
>         freopen("CON", "w", stdout); 

Let me be the first of no doubt many people to point out that this does not
redirect stdin back to normal. If the program you were running was already
redirected, that redirection will be lost.

To really do this right you need to use a lower-level routine. Observe
followups...
-- 
 _--_|\  Peter da Silva. +1 713 274 5180. <peter at ficc.uu.net>.
/      \
\_.--._/ Xenix Support -- it's not just a job, it's an adventure!
      v  "Have you hugged your wolf today?" `-_-'



More information about the Comp.lang.c mailing list