This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Madness with the 'select' function, sigalrm, and stdout. (CYGWIN_NT-6.1-WOW64)

On 1/17/2012 5:25 PM, Larry Hall (Cygwin) wrote:
On 1/17/2012 5:16 PM, Robert F wrote:
This could be a cygwin bug, but I'm not 100% sure. It may even be a weird
interaction with the windows console.

I have a single threaded app that loops, polls network activity with a
function and interrupts the flow of the loop when a SIGALRM signal is ran,
handler of which sets a variable that the loop responds to.

While this app more-or-less ran fine in its native linux environment, when
trying to run it at home in cygwin a problem occurs. Basically, between about
2-100 seconds of starting the process (on average), the alarm signal never
as scheduled and never runs again, except for one more time when I hit CTRL+C
(which I know by inserting debugging output into the signal handler).

The funny thing is the app happily continues looping and calling the 'select'
function, it just never gets interrupted by an alarm signal. The select
handles cases of EINTR where it was interrupted by an alarm, btw (sockets are
nonblocking and timeout is 1 second).

Now here's the REALLY weird bit. IF I insert a printf (with newline
string) after the select function, _the problem never occurs_. If there's no
newline, the printed strings are buffered without being shown, until either a
newline arrives or I hit CTRL-C.

Doesn't work if I put it before the select function, only after.

I haven't included any io streams into the fd_sets passed to the select
function, in case you were wondering. They are zeroed and then only receive
network connections.

This has me stumped.

I'd suggest trying a snapshot - <>

If that doesn't help, a full problem report might help someone on the list
spot an issue.

Problem reports:



A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]