| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
gauche.termios - Termios This module defines POSIX termios interface, which controls terminal attributes. This module also provides pseudo tty interface, if the system provides it.
POSIX termios(7) structure.
The slots iflag, oflag, cflag and lflag
contains non-negative integers representing bitmasks.
The slot cc contains a copy of c_cc array
of struct termios, as an u8vector (see gauche.uvector - Uniform vectors
for the details about u8vector).
Since cc slot is a copy of the internal structure, you have
to set! an u8vector to the slot explicitly to make
changes to the c_cc array.
Throughout this section, argument port-or-fd refers to
either a port object or a small integer representing system's file
descriptor. If port is not associated
to the system terminal, an error is signalled. (You can check if port
has an associated terminal by sys-isatty?.
See section Other file operations).
Returns terminal parameters in a <sys-termios> object,
associated to port-or-fd.
Sets terminal parameters associated to port-or-fd by termios,
which must be an instance of <sys-termios>.
An integer argument when specifies when the changes take effect. Three variables are pre-defined for the argument:
TCSANOWThe change is reflected immediately.
TCSADRAINThe change is reflected after all pending output is flushed.
TCSAFLUSHThe change is reflected after all pending output is flushed, and all pending input is discarded.
Transmits a zero stream for the specified duration to the terminal associated to port-or-fd. The unit of duration depends on the system; see man tcsendbreak(3) of your system for details.
Waits until all output written to port-or-fd is transmitted.
Discards data in the buffer of port-or-fd, specified by queue, which may be one of the following values.
TCIFLUSHDiscards data received but not read.
TCOFLUSHDiscards data written but not transmitted.
TCIOFLUSHDo both TCIFLUSH and TCOFLUSH action.
Controls data flow of port-or-fd by action, which may be one of the following values:
TCOOFFSuspends output transmission.
TCOONRestarts output transmission.
TCIOFFTransmits a STOP character to make the terminal device stop transmitting data to the system.
TCIONTransmits a START character to make the terminal device resume transmitting data to the system.
Returns process group ID of the terminal associated to port-or-fd.
Sets process group ID of the terminal associated to port-or-fd to pgrp.
Gets/sets input/output speed (baud rate) parameter stored in termios
object. Speed is represented by the following predefined numbers:
B0, B50, B75, B110, B134,
B150, B200, B300, B600, B1200,
B1800, B2400, B4800, B9600,
B19200, B38400.
Some system may support higher baud rate, such as B57600,
B115200 or B230400. You can use symbol-bound?
to check these options are defined. B0 is used to
terminate the connection.
Opens a pair of pseudo ttys, one for master and the other for slave,
then returns two integers which are their file descriptors.
An optional argument term must be, if passed, a <sys-termios>
object; it sets the slave pty's parameters.
You can use open-input-fd-port and/or open-output-fd-port
to create a port around the returned file descriptor (See section File ports).
To obtain pseudo tty's name, use sys-ttyname
(See section Other file operations).
This function is available only if the system supports openpty(3).
Opens a pair of pseudo ttys, one for master and the other for slave, sets the slave pty suitable for login terminal, then fork(2).
Returns two integers; the first value is a child pid for the parent process, and 0 for the child process. The second value is a file descriptor of the master pty.
An optional argument term must be, if passed, a <sys-termios>
object; it sets the slave pty's parameters.
This function is available only if the system supports forkpty(3).
Note: sys-forkpty has the same MT hazard as sys-fork
(see Unix process management, for details). If you're
running multiple threads, use sys-forkpty-and-exec below.
Does sys-forkpty, and lets the child process
immediately execs the specified command
with arguments args. This function doesn't have
the hazard in multi-thread environment.
The meanings of arguments command, args, iomap and
sigmask
are the same as sys-exec (see Unix process management).
If the keyword argument term is given, it is used to initialize
the slave pty.
The following example shows how to get a password from the user without echoing:
(use gauche.termios)
(define (get-password prompt)
(let* ((port (current-input-port))
(attr (sys-tcgetattr port))
(lflag (slot-ref attr 'lflag)))
;; Show prompt
(display prompt)
(flush)
;; Turn off echo during reading.
(dynamic-wind
(lambda ()
(slot-set! attr 'lflag (logand lflag (lognot ECHO)))
(sys-tcsetattr port TCSAFLUSH attr))
(lambda ()
(read-line port))
(lambda ()
(slot-set! attr 'lflag lflag)
(sys-tcsetattr port TCSANOW attr)))))
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Shiro Kawai on October, 7 2008 using texi2html 1.78.