Subject: - stdin read problem
From: "Alexey Zakharov" <[email-masked]>
To: [email-masked], [email-masked], [email-masked]
Cc: [email-masked]
Date: Fri, 25 Apr 2008 18:38:56 +0400
List-Id: <cygwin.cygwin.com>

Hi,

I've attached simple cpp program which demonstrates the problem.
The program works fine from cmd.exe, but fails when started from cygwin.

The program does the following:
- The main thread creates a helper thread which reads stdin and prints
the data read.
- stdin is read via ReadFile() Win32 API function.
- At the end of the main function, the main thread calls CloseHandle()
func for the stdin. It causes the ReadFile() function to return, and
the helper thread to finish. From cmd the program works as described.
- Under Cygwin  the program works differently. The helper thread is
not finished, because it doesn't exit from the ReadFile() func. The
main thread waits for the helper thread's completion during 1 sec,
then it calls TerminateThread() Win32 API func.

When I start the program from cmd, I see the following output:
>read_stdin_example.exe
Stdin_Reader_Thread has been completed

When I start the program from Cygwin, I see:
$ ./read_stdin_example.exe
Stdin_Reader_Thread has NOT been completed. So, it will be terminated.

I believe that this information would be enough to investigate and fix
the problem.
If you need more information or have questions, feel free to contact me.

Have a nice day!
~Alexey
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/