Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI727.ASC

 
Output of file : TI727.ASC contained in archive : BCPPTECH.ZIP







PRODUCT : Borland C++ NUMBER : 727
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 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. */



























  3 Responses to “Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI727.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/