disperl/src/disperl.cxx
/////////////////////////////////////////////////////////////////////// 
// ReadAndHandleOutput
// Monitors handle for input. Exits when child exits or pipe breaks.
///////////////////////////////////////////////////////////////////////
ReadAndHandleOutput
Monitors handle for input. Exits when child exits or pipe breaks.
ReadAndHandleOutput Monitors handle for input . Exits when child exits or pipe breaks .
void ReadAndHandleOutput(HANDLE hPipeRead,HANDLE hOutputFile)
   {
      CHAR lpBuffer[256];
      DWORD nBytesRead;
      DWORD nCharsWritten;
      while(TRUE)
      {
         if (!ReadFile(hPipeRead,lpBuffer,sizeof(lpBuffer),
                                          &nBytesRead,NULL) || !nBytesRead)
         {
            if (GetLastError() == ERROR_BROKEN_PIPE)
               break; 
            else
               DisplayError("ReadFile ReadAndHandleOutput",hOutputFile); 
         }
         if (!WriteFile(hOutputFile,lpBuffer,
                           nBytesRead,&nCharsWritten,NULL))
            DisplayError("WriteFile ReadAndHandleOutput",hOutputFile);
      }
   }
void ReadAndHandleOutput ( HANDLE hPipeRead , HANDLE hOutputFile ) { CHAR lpBuffer [ 256 ] ; DWORD nBytesRead ; DWORD nCharsWritten ; while ( TRUE ) { if ( ! ReadFile ( hPipeRead , lpBuffer , sizeof ( lpBuffer ) , & nBytesRead , NULL ) || ! nBytesRead ) { if ( GetLastError ( ) == ERROR_BROKEN_PIPE ) break ; else DisplayError ( " " , hOutputFile ) ; } if ( ! WriteFile ( hOutputFile , lpBuffer , nBytesRead , & nCharsWritten , NULL ) ) DisplayError ( " " , hOutputFile ) ; } }
ReadAndHandleOutput
Monitors handle for input.
ReadAndHandleOutput Monitors handle for input .
// pipe done - normal exit path. // Something bad happened. // Display the character read on the screen.