Search code examples
posix

what if _POSIX_VDISABLE value is -1?


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


Solution

  • 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 the ERASE character (usually DEL) for editing input, and other editing characters.
    The INTR character (normally Ctrl-c) for sending a SIGINT 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.