If the ioctl fails to tell us the winsize, default to 79.
authorEric Andersen <andersen@codepoet.org>
Wed, 31 Jan 2001 00:30:45 +0000 (00:30 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 31 Jan 2001 00:30:45 +0000 (00:30 -0000)
 -Erik

cmdedit.c
shell/cmdedit.c

index 9c2facc7b0ad410a061bba24836c39e86fe0eedf..1690326976ff52d5637adbcd56523b24b286fa12 100644 (file)
--- a/cmdedit.c
+++ b/cmdedit.c
@@ -136,11 +136,14 @@ static void win_changed(int nsig)
        struct winsize win = { 0, 0, 0, 0 };
        static __sighandler_t previous_SIGWINCH_handler; /* for reset */
 
-          /* emulate signal call if not called as a sig handler */
+       /* emulate signal call if not called as a sig handler */
        if(nsig == -SIGWINCH || nsig == SIGWINCH) {
                ioctl(0, TIOCGWINSZ, &win);
                if (win.ws_col > 0) {
                        cmdedit_setwidth( win.ws_col, nsig == SIGWINCH );
+               } else {
+                       /* Default to 79 if their console doesn't want to share */
+                       cmdedit_setwidth( 79, nsig == SIGWINCH );
                }
        }
        
index 9c2facc7b0ad410a061bba24836c39e86fe0eedf..1690326976ff52d5637adbcd56523b24b286fa12 100644 (file)
@@ -136,11 +136,14 @@ static void win_changed(int nsig)
        struct winsize win = { 0, 0, 0, 0 };
        static __sighandler_t previous_SIGWINCH_handler; /* for reset */
 
-          /* emulate signal call if not called as a sig handler */
+       /* emulate signal call if not called as a sig handler */
        if(nsig == -SIGWINCH || nsig == SIGWINCH) {
                ioctl(0, TIOCGWINSZ, &win);
                if (win.ws_col > 0) {
                        cmdedit_setwidth( win.ws_col, nsig == SIGWINCH );
+               } else {
+                       /* Default to 79 if their console doesn't want to share */
+                       cmdedit_setwidth( 79, nsig == SIGWINCH );
                }
        }