PRODUCT : Borland C++ NUMBER : 727 VERSION : 2.0 OS : DOS DATE : October 19, 1993 PAGE : 1/1 TITLE : Redirecting Output Before Spawn /************************************************************ How to redirect output before spawning a child process. ************************************************************/ FILE *fp; int handle; fp=fopen( ); /* in this case, use "NUL" as the file, this is DOS's NULL device */ handle=dup(fileno(stdout)); dup2(fileno(fp),fileno(stdout)); execlp ( ); dup2(handle,fileno(stdout)); /*This will duplicate the file handle stdout to the FILE pointer fp. Then dup2 is used to replace stdout with the new file opened with fopen. Next, make your call to spawn. Finally, use dup2 with the saved handle variable to restore stdout. */ DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.