Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!nuchat!moray!urchin!p6.f506.n106.z1.fidonet.org!Bob.Stout From: Bob.Stout@p6.f506.n106.z1.fidonet.org (Bob Stout) Newsgroups: comp.lang.c Subject: Redirecting STDOUT using spawn Message-ID: <14466.25E403FD@urchin.fidonet.org> Date: 21 Feb 90 13:28:23 GMT Sender: ufgate@urchin.fidonet.org (newsout1.26) Organization: FidoNet node 1:106/506.6 - Fulcrum's Edge, Spring TX Lines: 14 In an article of <19 Feb 90 20:42:36 GMT>, (owen adair) writes: >How do I redirect stdout for a child process using spawn instead of >system? I wan tthe return codes that are available using spawn but you >cant pass the "> filename" stuff using spawn ..... Also, I need STDOUT to >return to normal... First of all, since you're using spawn rather than fork, I'll assume you're using DOS and answer accordingly, although the same techniques apply and the essential function is ANSI... freopen("FILE", "w", stdout); ercode = spawnlp(P_WAIT, "PROG.EXE", "PROG", "ARGS", NULL); freopen("CON", "w", stdout);