Re: [PATCH/RFC 1/5] mingw: make fgetc raise SIGINT if apropriate
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Dec 1, 2012, 12:36 UTC
- Message-ID
- <CABPQNSaCV820zhJGdW++LMf2U7AeODSbfukix3fMfffmNex4YA@mail.gmail.com>
- In-Reply-To
- <alpine.DEB.1.00.1211301857170.31987@s15462909.onlinehome-server.info>
On Fri, Nov 30, 2012 at 6:58 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 10 quoted lines
> Hi, > > On Tue, 13 Nov 2012, Erik Faye-Lund wrote: > >> Set a control-handler to prevent the process from terminating, and >> simulate SIGINT so it can be handled by a signal-handler as usual. > > One thing you might want to mention is that the fgetc() handling is not > thread-safe, and intentionally so: if two threads read from the same > console, we are in trouble anyway.
I'm not entirely sure if I know what you mean. Do you suggest that two threads can race for setting the console ctrl-handler? I don't think that's the case; "SetConsoleCtrlHandler(x, TRUE)" adds a console handler to the handler-chain, and SetConsoleCtrlHandler(x, FALSE) removes it. If two threads add handlers, it is my understanding that one of them will be run, only to report "no, no more ctrl-handling needed". Since both handlers block further ctrl-handling, I don't think there's a problem.
Do you care to clarify what your thread-safety complaint is?
> BTW I like the new mingw_raise() very much!
Thanks! I originally implemented it for a different reason, but that patch didn't turn out to be useful, so it's nice to finally put it to use ;)
-- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en