Mailing List Archive

Short question about module termios
Hello.

I am new to Python and am using module termios. Everything seems pretty
straightforward, with one exception: I don't know how to disable
special character handling. In other words, I don't know how to do what
the following C code does, where fd is an open tty:

#include <termios.h>

struct termios t ;
cc_t vdisable ;
long rv ;

vdisable = fpathconf(fd,_PC_VDISABLE) ;

t.c_cc[VINTR] = vdisable ;
t.c_cc[VQUIT] = vdisable ;
t.c_cc[VERASE] = vdisable ;
t.c_cc[VKILL] = vdisable ;
t.c_cc[VEOF] = vdisable ;

...and so on.

The only part I don't know how to do in Python is the fpathconf() part.
In other words, how do I get the proper value with which to disable a
special character? I have looked at TERMIOS.py, and I still don't know
how to do it. The rest is fairly clear to me. Any suggestions?

Thanks,
David Stein
Short question about module termios [ In reply to ]
David Stein <dstein@cts.ucla.edu> wrote:
: Hello.

: I am new to Python and am using module termios. Everything seems pretty
: straightforward, with one exception: I don't know how to disable
: special character handling. In other words, I don't know how to do what
: the following C code does, where fd is an open tty:

: #include <termios.h>

: struct termios t ;
: cc_t vdisable ;
: long rv ;

: vdisable = fpathconf(fd,_PC_VDISABLE) ;

: t.c_cc[VINTR] = vdisable ;
: t.c_cc[VQUIT] = vdisable ;
: t.c_cc[VERASE] = vdisable ;
: t.c_cc[VKILL] = vdisable ;
: t.c_cc[VEOF] = vdisable ;

: ...and so on.

: The only part I don't know how to do in Python is the fpathconf() part.
: In other words, how do I get the proper value with which to disable a
: special character? I have looked at TERMIOS.py, and I still don't know
: how to do it. The rest is fairly clear to me. Any suggestions?

The "vdisable" value is almost always the integer 0 (character 'nul').
It is probably quite safe to use that. The function fpathconf isn't
quite standard in the UNIX world, however using '\000' for disable is.

-Arcege