Re: poll() Bug in 10.4 / Darwin 8.0 ?
Re: poll() Bug in 10.4 / Darwin 8.0 ?
- Subject: Re: poll() Bug in 10.4 / Darwin 8.0 ?
- From: Dave Zarzycki <email@hidden>
- Date: Thu, 19 May 2005 08:22:14 -0700
Bug number 3710161 at Apple is tracking this. In short, kqueue and
poll on anything in /dev does not behave correctly.
davez
On May 19, 2005, at 8:09 AM, Steven Palm wrote:
I was trying to use a program I've used for a long time in 10.2 and
10.3, a terminal emulator "shim" called "wy60".
I haven't tried to wrap this in any sort of simple test case, nor
have I filed this as a bug. I thought I'd make sure it was worthy
of being filed and not a programming error, although the code does
work on various unixes as-is.
Also, if this is terribly off-base for this group, I apologize, but
it's decidedly at a Darwin level, no GUI (except possibly curses
and terminal stuff) involved here.
Here are some notes (and workaround) I had posted to the wy60
group, with the author's response:
In trying wy60 on MacOS X 10.4 (Tiger), I'm having an odd blocking
issue that does not happen with 10.2 or 10.3.
I end up here by tracing with gdb:
#0 0x90013784 in read ()
#1 0x00007d44 in readResponse (timeout=500, query=0x15a74 "\033
[0c", buffer=0xbffff424 "", firstChar=27, lastChar=99, discard=0,
maxLength=80) at wy60.c:3127
#2 0x00010458 in initTerminal (pty=-1) at wy60.c:4919
#3 0x000134e0 in main (argc=1, argv=0xbffff628) at wy60.c:6123
The hang is here:
do {
switch (poll(descriptors, 1, 0)) {
case -1:
case 0:
i = 0;
break;
default:
i = sizeof(extraData) - extraDataLength;
if (i == 0) {
*buffer = '\000';
return(buffer);
} else if ((count = read(0, extraData + extraDataLength, i))
> 0) {
extraDataLength+= count;
} else
i = 0;
}
} while (i);
It appears to hang on the read call.
info locals shows:
descriptors = {{
fd = 0,
events = 1,
revents = 32
}}
ptr = 0xbffff424 ""
i = 1023
j = -1073744832
count = 1
state = 0
Now, why this is an issue in 10.4 and was not in any earlier
version, I do not know. I first attempted to run the binary from
an earlier system without luck, and then compiled a fresh copy on
the 10.4 machine and it has the same problem.
Well, the fix seems easy enough, but the underlying answer not so
easy....
I simply edited my config.h to remove HAVE_POLL_H so it wouldn't
use the system poll call, and it now works using select and/or poll
emulation. My thinking was that poll() was telling the system it
had data to read when it really didn't have anything there.
I see the author of the tun/tap kext for MacOS X also claims the
poll() call is broken for character devices in Darwin8.
The author of wy60 responded with:
For some reason, it seems to think that stdin is not a valid file
descriptor. Not quite sure why that would happen. But in any case,
can you try adding
if (!(descriptors->revents & POLLIN))
i = 0;
else
before the line that reads
if (i == 0)
This should make the code stop trying to read from stdin, if poll
returned with anything other than POLLIN.
Hopefully, if I understand your problem description correctly, this
will fix the bug that you are seeing. Although, you might now run
the risk of occasionally seeing garbage characters when you press
function keys. If that happens, we'll need to take a closer look at
what the system calls are actually returning in all of these cases.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-userlevel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40n9yty.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden