stty()" -- System Call (libc)" "

Set terminal modes

##iinncclluuddee &&lltt;;ssggttttyy..hh&&ggtt;;
iinntt ssttttyy((_f_d_, _s_g_p))
iinntt _f_d;;
ssttrruucctt ssggttttyybb **_s_g_p;;

The COHERENT system call stty() sets a terminal's attributes. See the Lexicon article for stty for information on terminal attributes and their legal values.

Example

This example demonstrates both stty() and gtty(). It sets terminal input to read one character at a time (that is, it reads the terminal in ``raw'' form). When you type `q', it restores the terminal to its previous settings, and exits. For an additional example, see the ppiippee Lexicon article.
#include <sgtty.h>
main()
{
     struct sgttyb os, ns;
     char buff;
     printf("Waiting for q\n");
     gtty(1, &os); /* save old state */
     ns = os;          /* get base of new state */
     ns.sg_flags |= RAW;/* prevent <ctl-c> from working */
     ns.sg_flags &= ~(ECHO|CRMOD);/* no echo for now... */
     stty(1, &ns); /* set mode */
     do {
          buff = getchar();/* wait for the keyboard */
     } while(buff != 'q');
     stty(1, &os);/* reset mode */
}

Files

&&lltt;;ssggttttyy..hh&&ggtt;; -- Header file

See Also

Notes

Please note that if you use stty() to change the baud rate on a port, you must first invoke sleep(). If you do not, the port reverts back to its default settings.