[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev 2.8.1 fails under cron (with ncurses & nsl-fork)
From: |
Bela Lubkin |
Subject: |
Re: lynx-dev 2.8.1 fails under cron (with ncurses & nsl-fork) |
Date: |
Wed, 2 Dec 1998 15:32:26 -0800 |
Tom Dickey wrote:
> ok - it is not an ncurses bug, but a small error in Bela's nsl-fork logic that
> happens to be ifdef'd to exclude slang (he neglected to check that
> stdin is a tty in that chunk). I've a fix, am about 1/3 through integrating
> other patches. fyi:
>
> > diff -u HTTCP.c.orig HTTCP.c
> --- HTTCP.c.orig Wed Nov 18 14:45:34 1998
> +++ HTTCP.c Tue Dec 1 21:41:30 1998
> @@ -539,7 +539,7 @@
> ** selectable! /dev/null isn't, on some systems, which
> ** makes some useful Lynx invocations fail. -BL
> */
> - if (ok_to_select_stdin == -1) {
> + if ((ok_to_select_stdin == -1) && isatty(fileno(stdin))) {
> timeout.tv_sec = 0;
> timeout.tv_usec = 0;
> FD_SET(0, &readfds); /* stdin -BL */
> @@ -548,7 +548,7 @@
> else ok_to_select_stdin = 0;
> FD_ZERO(&readfds);
> }
> - if (ok_to_select_stdin) FD_SET(0, &readfds);
> + if (ok_to_select_stdin == 1) FD_SET(0, &readfds);
> #endif /* USE_SLANG */
> timeout.tv_sec = 1;
> timeout.tv_usec = 0;
What you really mean here is to set ok_to_select_stdin to 0 if not
isatty. I had resisted that because I thought there might be some
useful case where stdin wasn't a tty, but you might still want to be
able to interrupt with it; but now, thinking about that, it seems like a
lot of nonsense. So use this instead. It's simpler, less likely to
break anywhere.
Also, BTW, I don't know that this *wouldn't* work with slang. I just
don't have a test setup with slang. If someone who uses slang would
like to try it without that particular #ifdef USE_SLANG, we can probably
remove the #ifdef. (Maybe John E. Davis can comment...)
>Bela<
*** HTTCP.c.orig Wed Nov 18 11:23:55 1998
--- HTTCP.c Wed Dec 2 15:21:27 1998
***************
*** 456,458 ****
int child_exited = 0;
- int ok_to_select_stdin = -1;
--- 456,457 ----
***************
*** 536,552 ****
** users must live with up-to-1s timeout. -BL
- **
- ** Whoops -- we need to make sure stdin is actually
- ** selectable! /dev/null isn't, on some systems, which
- ** makes some useful Lynx invocations fail. -BL
*/
! if (ok_to_select_stdin == -1) {
! timeout.tv_sec = 0;
! timeout.tv_usec = 0;
! FD_SET(0, &readfds); /* stdin -BL */
! selret = select(1, &readfds, NULL, NULL, &timeout);
! if (selret >= 0) ok_to_select_stdin = 1;
! else ok_to_select_stdin = 0;
! FD_ZERO(&readfds);
! }
! if (ok_to_select_stdin) FD_SET(0, &readfds);
#endif /* USE_SLANG */
--- 535,538 ----
** users must live with up-to-1s timeout. -BL
*/
! if (isatty(fileno(stdin))) FD_SET(fileno(stdin), &readfds);
#endif /* USE_SLANG */