nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] [PATCH] winio: fix initial state of blocking-io


From: Lion Yang
Subject: Re: [Nano-devel] [PATCH] winio: fix initial state of blocking-io
Date: Sun, 05 Nov 2017 00:17:51 +0800

Here's a test program:

    #include <sys/ioctl.h>
    int main() {
      int set = 1;
      ioctl(0, FIONBIO, &set);
    }

After running this, `nano` fails with "Too many errors from stdin".

The same thing happens on `cat`: "Resource temporarily unavailable".

2017/11/04 午後11:16 Lion Yang <address@hidden>:
winio.c assumes waiting_mode = TRUE but stdin can be non-blocking
when a program (before nano) turned stdin to non-blocking mode and did not
recover it (or crashed before recovering blocking mode). This commit
set stdin blocking mode in nano.c

This should fix the bug reported in
"[Help-nano] Too many errors from stdin"
from Roman Tereshkov.
That was because nano treat the stdin as blocking (`static bool waiting_mode = TRUE`),).
Nano tried to do `input = wgetch(win)`, but obviously it always returns ERR in non-blocking mode,
and the branch `if (input == ERR && !waiting_mode) ... return;` had no effect.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]