c++ - Read and Write to Windows pipes in separate threads -


in program start thread redirect output console:

  while(true)   {      if (!readfile(hpiperead,lpbuffer,sizeof(lpbuffer),                                       &nbytesread,null) || !nbytesread)      {         if (getlasterror() == error_broken_pipe)            break; // pipe done - normal exit path.         else            displayerror("readfile"); // bad happened.      }       // display character read on screen.      if (!writeconsole(getstdhandle(std_output_handle),lpbuffer,                        nbytesread,&ncharswritten,null))         displayerror("writeconsole");   } 

the problem is loop. possible to avoid run of loop making thread wait until appears in pipe?

the problem becomes more intense when there analogous thread writing.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -