On Sat, Jun 09, 2012 at 10:36:00AM +0200, Sven Joachim wrote: > On 2012-06-09 09:47 +0200, Sven Joachim wrote: > > > On 2012-06-09 01:51 +0200, Thomas Dickey wrote: > > > >> The exit code is inverted: it is true if nonzero, which could be > >> -1 or some number greater than zero (the latter would indicate some > >> input happening, though which of the cases is hard to tell). > > > > Aah, of course. Now this makes sense even to me. > > However, I still have some problems understanding the test: in the > "else" branch, isn't it guaranteed that ret >= 0, no matter what? > The following makes more a bit more sense to me:
man poll:
RETURN VALUE
On success, a positive number is returned; this is the number of struc-
tures which have non-zero revents fields (in other words, those
descriptors with events or errors reported). A value of 0 indicates
that the call timed out and no file descriptors were ready. On error,
-1 is returned, and errno is set appropriately.
> --8<---------------cut here---------------start------------->8---
> diff --git a/aclocal.m4 b/aclocal.m4
> index f5a7260..304ddba 100644
> --- a/aclocal.m4
> +++ b/aclocal.m4
> @@ -1730,7 +1730,7 @@ int main() {
> myfds.revents = 0;
>
> ret = poll(&myfds, 1, 100);
> - if (ret < 0) {
> + if (ret > 0) {
> ret = 0;
> }
> }
> --8<---------------cut here---------------end--------------->8---
>
> Or, since you no longer check for ret != 0, but rather ret < 0 at the
> end:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/aclocal.m4 b/aclocal.m4
> index f5a7260..9270878 100644
> --- a/aclocal.m4
> +++ b/aclocal.m4
> @@ -1730,9 +1730,6 @@ int main() {
> myfds.revents = 0;
>
> ret = poll(&myfds, 1, 100);
> - if (ret < 0) {
> - ret = 0;
> - }
ouch - I think you're right.
(for next week - I'm out the rest of the weekend)
> }
> ${cf_cv_main_return:-return}(ret < 0);
> }],
> --8<---------------cut here---------------end--------------->8---
>
> Also, shouldn't the test check whether opening /dev/tty was actually
> successful?
I assumed in that instance that poll would simply fail :-)
>
> Cheers,
> Sven
>
>
--
Thomas E. Dickey <[email protected]>
http://invisible-island.net
ftp://invisible-island.net
signature.asc
Description: Digital signature

