nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] error while using nano in a chroot


From: David Lawrence Ramsey
Subject: Re: [Nano-devel] error while using nano in a chroot
Date: Thu, 06 Oct 2005 00:56:25 -0400
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050716)

Mike Frysinger wrote:

>i do a lot of development in chroots and nano doesnt seem to like those
>... this bug has been around for sometime, i just finally got annoyed
>enough to look into it :)

Oh good. :)

<snip>

>whenever i launch nano in a chroot and resize the terminal, it closes
>with:
>Received SIGHUP or SIGTERM
>sometimes if i bg/fg a few times, the same thing will happen
>
>it's lying of course, it received no such signal ... the
>get_key_buffer() function calls wgetch() which returns ERR so
>handle_hupterm(0) is called and this message is displayed
>
>can anything be done about it or should i just keep living with it ? :)

I've looked into it.  I don't have the time right now to set up a chroot
with nano 1.3.x available on my system, but I have noted that the
problem with the input source's being destroyed sets errno to EIO.  If
wgetch() is returning ERR for another reason, errno should have a
different value, and so it should just call wgetch() again until it gets
a non-ERR value (since the buffering code will screw up if it gets an
ERR in blocking mode).

If I'm right, the attached patch against current CVS should fix the
problem.  Would you let me know whether it does or not?  Thanks in
advance.

diff -ur nano/src/winio.c nano-fixed/src/winio.c
--- nano/src/winio.c    2005-10-03 23:41:32.000000000 -0400
+++ nano-fixed/src/winio.c      2005-10-06 00:39:11.000000000 -0400
@@ -27,6 +27,7 @@
 #include <stdarg.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 #include <ctype.h>
 #include "proto.h"
 
@@ -142,12 +143,13 @@
      * screen updates. */
     doupdate();
 
-    input = wgetch(win);
+    while ((input = wgetch(win)) == ERR) {
+       /* If errno is EIO, it means that the input source that we were
+        * using is gone, so die gracefully. */
+       if (errno == EIO)
+           handle_hupterm(0);
+    }
 
-    /* If we get ERR when using blocking input, it means that the input
-     * source that we were using is gone, so die gracefully. */
-    if (input == ERR)
-       handle_hupterm(0);
 
 #ifndef NANO_SMALL
     allow_pending_sigwinch(FALSE);

reply via email to

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