cbreak mode

cbreak mode

Post by Sho Kuwamo » Tue, 02 Jan 1990 05:48:00



        I tried using cbreak mode for the first time today,
and just like all other things, I failed miserably on my
first attempt.  Since I was already using curses in my program,
I first used the curses functions cbreak() and nocbreak().
After debugging, I found that the program

#include <stdio.h>
#include <curses.h>

main()
{
   cbreak();
   nocbreak();

Quote:}

would leave the machine in cbreak mode.  Furthermore, I
wrote my own routines to set and unset cbreak mode using
ioctl() and had the same result.  Am I just being a twit,
or and I lodged firmly in the Twilight Zone(TM)?  By the
way, our system runs 4.3bsd.

                                Thanx

                                -Sho

 
 
 

cbreak mode

Post by Andrew Sieg » Tue, 02 Jan 1990 13:27:00


Quote:> ... I found that the program

> #include <stdio.h>
> #include <curses.h>

> main()
> {
>    cbreak();
>    nocbreak();
> }

> would leave the machine in cbreak mode.  Furthermore, I
> wrote my own routines to set and unset cbreak mode using
> ioctl() and had the same result.

If you're using curses, you must begin your program with a call to
initscr(), and terminate it with endwin().  The endwin() call returns
the tty parameters to their original setting.

Good luck.
--
Andrew Siegel, N2CN             NBC Computer Imaging, New York, NY
philabs!nbc1!abs                (212)664-5776

 
 
 

cbreak mode

Post by n.. » Tue, 02 Jan 1990 01:53:00



>> ... I found that the program

>> #include <stdio.h>
>> #include <curses.h>

>> main()
>> {
>>    cbreak();
>>    nocbreak();
>> }

>> would leave the machine in cbreak mode.  
>If you're using curses, you must begin your program with a call to
>initscr(), and terminate it with endwin().  The endwin() call returns
>the tty parameters to their original setting.

The function initscr() needs to be called before screen and window
functions only.  cbreak() and nocbreak() are not screen or window
functions so it shouldn't have to be called.  Calling endwin() does
call resetty() which does restore the terminal settings but nocbreak()
should take the terminal out of cbreak mode.  As far as why this
doesn't work...  I dunno;  I have found problems like this before with
curses and terminal modes and have managed to avoid them but never fix
them.

                                Neil



uucp:   {decvax!watmath}
        {pur-ee!rocks34!rocksvax}
        {{allegra, seismo}!rochester!rocksvax} !sunybcs!neil