in windows, how to have non-blocking stdin that is a redirected pipe? in windows, how to have non-blocking stdin that is a redirected pipe? windows windows

in windows, how to have non-blocking stdin that is a redirected pipe?


The order apprach, check there is input ready to read:

  • For console mode, you can use GetNumberOfConsoleInputEvents().
  • For pipe redirection, you can use PeekNamedPipe()


You could use async I/O to read from the handle, such as the ReadFileEx() WIN32 call. Use CancelIo() to terminate reading in the absence of input.

See MSDN at http://msdn.microsoft.com/en-us/library/aa365468(VS.85).aspx