This is the mail archive of the
mailing list for the Cygwin project.
Re: 1.7.7: stdio functions block each other in a multithreaded program
On Jan 26 11:23, Corinna Vinschen wrote:
> On Jan 25 14:31, email@example.com wrote:
> > I am trying to make a multi-threaded application, where one thread reads
> > commands from stdin, and another thread is doing other things, such as
> > reading files and printing messages to stdout.
> > The problem I have is that the thread that reads files and writes to stdout
> > locks while the other thread is reading from stdin. To demonstrate this,
> > I created a small program that has this behavior. The C-code is present at
> > the end of this e-mail.
> > [...]
> Thanks for the testcase!
> First of all, I can confirm your observation and your testcase easily
> allows to debug what happens. What happens is that the read operation
> in scanf and the read operation in fgetc are blocking each other out
> because they access the same global lock.
> I could track down this behaviour to a specific change in newlib from
> 2009, which also explains why this still worked in 1.5 (which I tested
> as well).
> So, the next task for me is to find out why this change has been made
> and to talk to the contributor of the change to come to a solution
> which does not show this unfortunate behaviour.
> What you can do for the time being is to use the low-level IO functions
> read and write, rather than the stdio functions fgetc and putchar, since
> only the stdio functions are affected by this.
> I hope to find a solution soon and the bugfix will definitely be in 1.7.8.
After some discussion with my newlib co-maintainer I checked in a patch
which should solve your problem. Your testcase works fine for me now
when using the latest developer snapshot(*) from today.
Please give it a test in your environment.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple