Closed Bug 344195 Opened 18 years ago Closed 18 years ago

PR_Poll won't poll special stdin FD for PR_POLL_READ on Windows

Categories

(NSPR :: NSPR, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: nelson, Assigned: wtc)

References

Details

The behavior of PR_Poll on the special NSPR file destriptor for stdin 
is inconsistent accross platforms.  It doesn't work as expected on Windows.

Consider:
    pollset[0].fd        = s;
    pollset[0].in_flags  = PR_POLL_READ;
    pollset[1].fd        = PR_GetSpecialFD(PR_StandardInput);
    pollset[1].in_flags  = PR_POLL_READ;
    npds                 = 2;
    filesReady = PR_Poll(pollset, npds, PR_INTERVAL_NO_TIMEOUT);

On Unix, PR_Poll will tell us whether or not there is data readable on stdin.
On Windows, it will not.  

This has been known since before 2000/03/31, but I could not find any 
bugzilla bug that reported it.

I could not find any documentation on *.mozilla.org that documented this 
issue, or that said this is the defined behavior of NSPR on Windows.

IMO, we should either fix this or document it to be the defined behavior.
Wan-Teh, what is your preference?
On Windows, the select() function in the Winsock library can
only be used with sockets.  PR_Poll has the same limitation
on Windows because it is implemented with select().

I just documented this limitation in the NSPR Reference:
http://www.mozilla.org/projects/nspr/reference/html/priofnc.html#19653
http://developer.mozilla.org/en/docs/PR_Poll
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → WONTFIX
Target Milestone: --- → 4.7
Is there any other way, besides "select", to wait for multiple FDs to 
become ready?

Can WaitForMultipleObjects be used for this purpose? 
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/waitformultipleobjects.asp>
WaitForMultipleObjects has its own problems.  It can
only wait for at most 64 handles.  (In contrast, NSPR
defines FD_SETSIZE as 1024 on Windows.)  I'm also not
sure what kind of handles can be used to report I/O
availability of the standard input and output.
You need to log in before you can comment on or make changes to this bug.