2 ms·
I don't think it's evaluable. > If none of the defined events have occurred on any selected file descriptor Note the "on any selected file descriptor". If the
by eridius 10y ago
I don't think it's evaluable.
> If none of the defined events have occurred on any selected file descriptor
Note the "on any selected file descriptor". If there aren't any selected file descriptors to begin with, then the question doesn't even make sense. I can see how you could read it as saying it should sleep, but strictly speaking it seems like this is undefined behavior.
- lmm 10y agoThe question absolutely makes sense. There are no selected file descriptors. Trivially that means no event has occurred on any selected file descriptor. There is nothing undefined here.
- eridius 10y agoYou're taking one particular interpretation and treating that as the absolute truth. It's not. You've got a liberal interpretation, and a strict interpretation leaves it undefined. Just because you don't think it should be interpreted strictly doesn't mean the strict interpretation isn't a valid way to read it.
- lmm 10y agoNo, it really doesn't. That's what the world "any" means. There is no possible valid other way to read it. It's like saying "2 plus 2 is undefined, because if you interpret plus in a strict way the question is undefined".
- eridius 10y agoIf it was written "If there does not exist any selected file descriptor where a defined event has occurred", then I'd agree with you. But the way it's actually written presupposes that there are selected file descriptors.
- lmm 10y ago> But the way it's actually written presupposes that there are selected file descriptors. How so? It just says "If none of the defined events have occurred on any selected file descriptor, poll() shall wait at least timeout milliseconds for an event to occur on any of the selected file descriptors." "Any selected file descriptor" and "any of the selected file descriptors" make perfect sense for an empty array; nothing written there requires or implies any need for the array to be non-empty.
- eridius 10y agoWe're just going in circles already. It's already been explained that the way the question is written doesn't make sense if there are no file descriptors. I can see why you want to interpret it the way you do, but I don't understand why you refuse to admit that it's possible to read it such that this is undefined behavior.
- lmm 10y agoBecause this stuff is important! Functions that behave inconsistently with empty collections for no reason are a major source of bugs. And if you go as far as undefined behaviour then we're talking not just bugs but security bugs. Words have meanings. The document is supposed to be a specification. I care about having programs that work, and that requires OSes to actually follow the relevant specifications. The document is not ambiguous, there is nothing undefined here; a conforming implementation is clearly required to sleep the specified time when passed 0 fds.
- eridius 10y agoYou keep claiming it's not ambiguous and that nothing is undefined. I've explained repeatedly how the statement can be interpreted such that an empty set is undefined behavior, but you refuse to even acknowledge that this is a potential interpretation of the spec. Yes, the spec should be unambiguous, but that doesn't mean it actually is.