wd4fsu@kd4nc.UUCP (owen adair) (02/20/90)
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... Thanks!
Bob.Stout@p6.f506.n106.z1.fidonet.org (Bob Stout) (02/21/90)
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);
peter@ficc.uu.net (Peter da Silva) (02/24/90)
> 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@ficc.uu.net>. / \ \_.--._/ Xenix Support -- it's not just a job, it's an adventure! v "Have you hugged your wolf today?" `-_-'
brucem@dbase.A-T.COM (Bruce Madsen) (02/25/90)
>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? /* stuff deleted regarding spawn and stdio redirection. */ If you want to use the rawio operators (i.e. open read write), look at the man page for dup and dup2 in the microsoft C runtime library manual. They give an example on redirection. To redirect stdout, use 1 in for the file handle. Bruce Madsen -- * Hockey - The world's fastest sport* The proceeding has not been brought to * * Baseball - Sominex for the masses * you by Ashton-Tate. The above opinions * * Bo don't know database * are mine. * * B. G. Madsen - Ashton-Tate Glendale Development Center. brucem@dbase------*