- stdin read problem

Václav Haisman v.haisman@sh.cvut.cz
Fri Apr 25 14:56:00 GMT 2008


Alexey Zakharov wrote:
> 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
> 
Cross posting like this won't give you the kind of attention you seek.

--
VH

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin-talk/attachments/20080425/dc2823ea/attachment.sig>


More information about the Cygwin-talk mailing list