MSDN does not list pipe handles as waitable with WaitForMultipleObjectsEx (only a user comment at the end does). If you trace execution without PeekNamedPipe(), you'll see that WaitForMultipleObjectsEx() returns immediately, and that it is ReadFile() that blocks and waits for the input (which will be supplied after 3 seconds).
--quote-- The WaitForMultipleObjectsEx function can specify handles of any of the following object types in the lpHandles array: Change notification Console input Event Memory resource notification Mutex Process Semaphore Thread Waitable timer --quote-- Also from here: http://stackoverflow.com/questions/14203618/windows-api-wait-for-data-to-be-available-on-non-gui-console-input-pipe-based --quote-- Is it possible to wait for data to be available on a non-GUI-based console input? The issue is that WaitFor* methods do not support PIPE handles and therefore STDIN is not supported if the process input is fed from another process, e.g. using the pipe | functionality of cmd. The only way I know to query a pipe for data without actually reading the data is to use PeekNamedPipe(), but then you lose the ability to wait on a timeout effectively, because it has no timeout so you would have to implement a manual loop instead. --quote-- HTH, Anton Lavrentiev Contractor NIH/NLM/NCBI -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple