[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] tcsetattr: ISIG?



Hi

as I noticed, setting the flag ISIG in c_lflag affects the mapping
\nl->\cr\nl. I can't see any reason for this.


The libc-doc says:


 - Macro: tcflag_t ISIG
     This bit controls whether the INTR, QUIT, and SUSP characters are
     recognized.  The functions associated with these characters are
     performed if and only if this bit is set.  Being in canonical or
     noncanonical input mode has no affect on the interpretation of
     these characters.

     You should use caution when disabling recognition of these
     characters.  Programs that cannot be interrupted interactively are
     very user-unfriendly.  If you clear this bit, your program should
     provide some alternate interface that allows the user to
     interactively send the signals associated with these characters,
     or to escape from the program.



Check it with:

/*tc.c last change: Mon Sep 27 00:08:12 1999*/
#include <stdio.h>
#include <termios.h>

int put_lines( int fd, struct termios *t )
{
        int ret = tcsetattr(fd, TCSADRAIN, t);
        write( fd, "line\n", 6 );
        write( fd, "line\n", 6 );
        write( fd, "\nline", 6 );
        write( fd, "\nline", 6 );
        write( fd, "\n\n", 2 );
        write( fd, "line\r", 6 );
        write( fd, "line\r", 6 );
        write( fd, "\rline", 6 );
        write( fd, "\rline", 6 );
        getchar();
        return ret;
}

int main(void)
{
        int ret, fd = 1;
        struct termios t, told;

        ret = tcgetattr( fd, &t);
        told = t;

        puts( "t.c_iflag = (ICRNL|INLCR);" );
        t.c_iflag = (ICRNL|INLCR);
        put_lines( fd, &t );

        puts( "t.c_lflag &= ~(ISIG);" );
        t.c_lflag &= ~(ISIG);
        put_lines( fd, &t );

        puts( "t.c_lflag |= (ISIG);" );
        t.c_lflag |= (ISIG);
        put_lines( fd, &t );

        ret = tcsetattr(fd, TCSADRAIN, &told);
        return ret;
}
/* -- end of tc.c -- */