In POSIX _POSIX_VDISABLE value if -1, there is no disabling character for special character for all the terminal device files; otherwise the value is the disabling character value..
Can please anyone help me understand this. I m not able to get the exact meaning of this.
Please
My terminal has special keys, like ^C to interrupt, ^\ to dump core, ^W to erase a word, and ^U to erase a line. Special keys exist in xterm and other terminal emulators, but they are not the same in every terminal. POSIX apps can call tcgetattr() or tcsetattr() in <termios.h> to get or set these special keys. They can also disable some keys, for example:
tcgetattr(fd, tp);
tp->c_lflag &= ~ISIG; /* disable all the signal keys */
tp->c_cc[WERASE] = _POSIX_VDISABLE; /* disable the word-erase key */
tcsetattr(fd, tp);
Before POSIX.1-2001, support for _POSIX_VDISABLE was optional. There were 3 possibilities:
pathconf("/dev/tty", _PC_VDISABLE)
would return the value for that terminal, or -1 if that terminal doesn't have a value to disable a special key.When systems added <termios.h>, all or almost all systems made _POSIX_VDISABLE defined and not -1. I looked at some old systems in the Unix tree. All of Minix 1.5 (1989), Linux 0.96c (1992), and 4.4BSD (1993) have _POSIX_VDISABLE defined and not -1. (Before POSIX, <termios.h> did not exist, and systems used another header like <sgtty.h> to configure the terminal.)
POSIX-1.2001 simply required that _POSIX_VDISABLE is defined and not -1. POSIX.1-2001 said for <unistd.h>,
_POSIX_VDISABLE
This symbol shall be defined to be the value of a character that shall disable terminal special character handling as described in <termios.h>. This symbol shall always be set to a value other than -1.
The rationale says,
As part of the revision some alignment has occurred of the options with the FIPS 151-2 profile on the POSIX.1-1990 standard. The following options from the POSIX.1-1990 standard are now mandatory:
- _POSIX_JOB_CONTROL
- _POSIX_SAVED_IDS
- _POSIX_VDISABLE
If you look at the definition of special characters, that should mean (thre '-1' value), that all those special characters are active:
In canonical input, the terminal driver recognizes a number of special characters which perform various control functions.
These include theERASE
character (usually DEL) for editing input, and other editing characters.
The INTR character (normally Ctrl-c) for sending aSIGINT
signal, and other signal-raising characters, may be available in either canonical or noncanonical input mode.
And you have a lot of those specal characters:
The question has been raised to see if such a value was portable (did always compiled) in 1997:
The wording in section 2.9.4:
If any of the constants in Table 2-11 are defined to have value -1 in the header ....
can suggest, on casual reading, code like the following to minimize size and optimize efficiency for each implementation:
#ifdef _POSIX_VDISABLE
#if _POSIX_VDISABLE == -1
/* code that assumes no vdisable capability */
#else
/* code that assumes vdisable capability */
#endif
#else
/* code that uses pathconf() to determine vdisable capability */
#endif
The interpretation #34 suggests that it will.
By using these values at COMPILE-TIME, a portable POSIX.1 application can avoid loading all pathconf() related code associated with a symbol in Table 2-11 when the symbol is defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With