Provided by: manpages-de_1.11-1_all
BEZEICHNUNG
tty_ioctl - Ioctls für Terminals und serielle Leitungen
ÜBERSICHT
#include <termios.h> int ioctl(int fd, int cmd, …);
BESCHREIBUNG
Der ioctl(2)-Aufruf für Terminals und serielle Ports akzeptiert viele mögliche Befehlzeilenargumente. Die meisten erwarten ein drittes Argument, von verschiedenem Typ, hier argp oder arg genannt. Durch die Verwendung von ioctl entstehen nichtportierbare Programme. Verwenden Sie die POSIX-Schnittstelle, wie in termios(3) beschrieben, wann immer möglich. Terminal-Attribute ermitteln und setzen TCGETS struct termios *argp äquivalent zu tcgetattr(fd, argp) Einstellungen der aktuellen seriellen Schnittstelle ermitteln TCSETS const struct termios *argp äquivalent zu tcsetattr(fd, TCSANOW, argp) Einstellungen der aktuellen seriellen Schnittstelle setzen TCSETSW const struct termios *argp äquivalent zu tcsetattr(fd, TCSADRAIN, argp) Erlaubt dem Ausgabepuffer, leerzulaufen, und setzt die aktuellen Einstellungen serieller Ports. TCSETSF const struct termios *argp äquivalent zu tcsetattr(fd, TCSAFLUSH, argp) Erlaubt dem Ausgabepuffer, leerzulaufen, verwirft wartende Eingaben und setzt die aktuellen Einstellungen serieller Ports. Die folgenden vier Ioctls sind genau wie TCGETS, TCSETS, TCSETSW, TCSETSF, außer dass Sie ein struct termio * statt eines struct termios * erwarten. TCGETA struct termio *argp TCSETA const struct termio *argp TCSETAW const struct termio *argp TCSETAF const struct termio *argp Locking the termios structure The termios structure of a terminal can be locked. The lock is itself a termios structure, with nonzero bits or fields indicating a locked value. TIOCGLCKTRMIOS struct termios *argp Gets the locking status of the termios structure of the terminal. TIOCSLCKTRMIOS const struct termios *argp Sets the locking status of the termios structure of the terminal. Only a process with the CAP_SYS_ADMIN capability can do this. Fenstergröße ermitteln und setzen Fenstergrößen werden im Kernel gehalten, dort aber nicht verwandt (außer im Falle der virtuellen Konsolen, bei denen der Kernel die Fenstergrößen aktualisiert, wenn sich die Größe der virtuellen Konsolen ändert, beispielsweise durch Laden einer neuen Schriftart). Die folgenden Konstanten und Strukturen sind in <sys/ioctl.h> definiert. TIOCGWINSZ struct winsize *argp Fenstergröße ermitteln. TIOCSWINSZ const struct winsize *argp Fenstergröße setzen. Das von diesen Ioctls verwandte Struct ist wie folgt definiert: struct winsize { unsigned short ws_row; unsigned short ws_col; unsigned short ws_xpixel; /* unbenutzt */ unsigned short ws_ypixel; /* unbenutzt */ }; Wenn sich die Fenstergröße ändert wird das Signal SIGWINCH an die Vordergrund-Prozessgruppe gesandt. Senden einer Unterbrechung TCSBRK int arg äquivalent zu tcsendbreak(fd, arg) Falls das Terminal asynchrone Datenübertragung verwendet und arg Null ist, wird eine Unterbrechung (ein Strom von Null-Bits) für 0,25-0,5 Sekunden gesandt. Falls das Terminal keine asynchrone serielle Datenübertragung verwendet, wird entweder eine Unterbrechung gesandt oder die Funktion kommt ohne Aktion zurück. Falls arg nicht Null ist, ist die Aktion undefiniert. (SVr4, UnixWare, Solaris, Linux behandeln tcsendbreak(fd,arg) mit von Null verschiedenem arg wie tcdrain(fd). SunOS behandelt arg als Multiplikator und schickt einen Bitstrom der Länge arg-mal so lange wie bei arg gleich Null. DG/UX und AIX behandeln arg (wenn von Null verschieden) als Zeitintervall in Millisekunden. HP-UX ignoriert arg.) TCSBRKP int arg Sogenannte »POSIX-Version« von TCSBRK. Sie behandelt von Null verschiedene arg als in Dezisekunden gemessenes Zeitintervall und führt nichts aus, falls der Treiber Unterbrechungen nicht unterstützt. TIOCSBRK void Schaltet Unterbrechungen ein, d.h. beginnt den Versand von Null-Bits. TIOCCBRK void Schaltet Unterbrechungen aus, d.h. beendet den Versand von Null-Bits. Software-Flußsteuerung TCXONC int arg äquivalent zu tcflow(fd, arg) siehe tcflow(3) für die Argumentwerte TCOOFF, TCOON, TCIOFF, TCION Buffer count and flushing FIONREAD int *argp Die Anzahl der Bytes im Eingabepuffer ermitteln. TIOCINQ int *argp identisch zu FIONREAD TIOCOUTQ int *argp Die Anzahl der Bytes im Ausgabepuffer ermitteln. TCFLSH int arg äquivalent zu tcflush(fd, arg) siehe tcflush(3) für die Argumentwerte TCIFLUSH, TCOFLUSH und TCIOFLUSH Eingabe vortäuschen TIOCSTI const char *argp Das übergebene Byte in die Eingabewarteschlange einfügen. Konsoleausgabe umleiten TIOCCONS void Redirect output that would have gone to /dev/console or /dev/tty0 to the given terminal. If that was a pseudoterminal master, send it to the slave. In Linux before version 2.6.10, anybody can do this as long as the output was not redirected yet; since version 2.6.10, only a process with the CAP_SYS_ADMIN capability may do this. If output was redirected already EBUSY is returned, but redirection can be stopped by using this ioctl with fd pointing at /dev/console or /dev/tty0. Steuerndes Terminal TIOCSCTTY int arg Make the given terminal the controlling terminal of the calling process. The calling process must be a session leader and not have a controlling terminal already. For this case, arg should be specified as zero. If this terminal is already the controlling terminal of a different session group, then the ioctl fails with EPERM, unless the caller has the CAP_SYS_ADMIN capability and arg equals 1, in which case the terminal is stolen, and all processes that had it as controlling terminal lose it. TIOCNOTTY void If the given terminal was the controlling terminal of the calling process, give up this controlling terminal. If the process was session leader, then send SIGHUP and SIGCONT to the foreground process group and all processes in the current session lose their controlling terminal. Prozessgruppen- und -sitzungs-ID TIOCGPGRP pid_t *argp wenn erfolgreich, äquivalent zu *argp = tcgetpgrp(fd) Die Prozessgruppen-ID der Vordergrundprozessgruppe auf diesem Terminal ermitteln. TIOCSPGRP const pid_t *argp äquivalent zu tcsetpgrp(fd, *argp) Die Vordergrundprozessgruppen-ID dieses Terminals setzen. TIOCGSID pid_t *argp Get the session ID of the given terminal. This will fail with ENOTTY in case the terminal is not a master pseudoterminal and not our controlling terminal. Strange. Exklusiver Modus TIOCEXCL void Put the terminal into exclusive mode. No further open(2) operations on the terminal are permitted. (They will fail with EBUSY, except for a process with the CAP_SYS_ADMIN capability.) TIOCGEXCL int *argp If the terminal is currently in exclusive mode, place a nonzero value in the location pointed to by argp; otherwise, place zero in *argp (since Linux 3.8). TIOCNXCL void exklusiven Modus deaktivieren Line discipline TIOCGETD int *argp Get the line discipline of the terminal. TIOCSETD const int *argp Set the line discipline of the terminal. Pseudoterminal-Ioctls TIOCPKT const int *argp Enable (when *argp is nonzero) or disable packet mode. Can be applied to the master side of a pseudoterminal only (and will return ENOTTY otherwise). In packet mode, each subsequent read(2) will return a packet that either contains a single nonzero control byte, or has a single byte containing zero (' ') followed by data written on the slave side of the pseudoterminal. If the first byte is not TIOCPKT_DATA (0), it is an OR of one or more of the following bits: TIOCPKT_FLUSHREAD The read queue for the terminal is flushed. TIOCPKT_FLUSHWRITE The write queue for the terminal is flushed. TIOCPKT_STOP Output to the terminal is stopped. TIOCPKT_START Output to the terminal is restarted. TIOCPKT_DOSTOP The start and stop characters are ^S/^Q. TIOCPKT_NOSTOP The start and stop characters are not ^S/^Q. While this mode is in use, the presence of control status information to be read from the master side may be detected by a select(2) for exceptional conditions. This mode is used by rlogin(1) and rlogind(8) to implement a remote-echoed, locally ^S/^Q flow-controlled remote login. TIOGCPKT const int *argp Return the current packet mode setting in the integer pointed to by argp (since Linux 3.8). TIOCSPTLCK int *argp Set (if *argp is nonzero) or remove (if *argp is zero) the pseudoterminal slave device. (See also unlockpt(3).) TIOCGPTLCK int *argp Place the current lock state of the pseudoterminal slave device in the location pointed to by argp (since Linux 3.8). Die BSD-Ioctls TIOCSTOP, TIOCSTART, TIOCUCNTL, TIOCREMOTE wurden unter Linux nicht implementiert. Modem-Steuerung TIOCMGET int *argp Den Staus der Modem-Bits ermitteln. TIOCMSET const int *argp Den Staus der Modem-Bits setzen. TIOCMBIC const int *argp Die angegebenen Modem-Bits zurücksetzen. TIOCMBIS const int *argp Die angegebenen Modem-Bits setzen. Die folgenden Bits werden von den obigen Ioctls verwandt: TIOCM_LE DSR (data set ready/line enable) TIOCM_DTR DTR (data terminal ready) TIOCM_RTS RTS (request to send) TIOCM_ST Secondary TXD (transmit) TIOCM_SR Secondary RXD (receive) TIOCM_CTS CTS (clear to send) TIOCM_CAR DCD (data carrier detect) TIOCM_CD see TIOCM_CAR TIOCM_RNG RNG (ring) TIOCM_RI see TIOCM_RNG TIOCM_DSR DSR (data set ready) TIOCMIWAIT int arg Wait for any of the 4 modem bits (DCD, RI, DSR, CTS) to change. The bits of interest are specified as a bit mask in arg, by ORing together any of the bit values, TIOCM_RNG, TIOCM_DSR, TIOCM_CD, and TIOCM_CTS. The caller should use TIOCGICOUNT to see which bit has changed. TIOCGICOUNT struct serial_icounter_struct *argp Get counts of input serial line interrupts (DCD, RI, DSR, CTS). The counts are written to the serial_icounter_struct structure pointed to by argp. Note: both 1->0 and 0->1 transitions are counted, except for RI, where only 0->1 transitions are counted. Eine Leitung als lokal kennzeichnen TIOCGSOFTCAR int *argp ("Get software carrier flag") Get the status of the CLOCAL flag in the c_cflag field of the termios structure. TIOCSSOFTCAR const int *argp ("Set software carrier flag") Set the CLOCAL flag in the termios structure when *argp is nonzero, and clear it otherwise. If the CLOCAL flag for a line is off, the hardware carrier detect (DCD) signal is significant, and an open(2) of the corresponding terminal will block until DCD is asserted, unless the O_NONBLOCK flag is given. If CLOCAL is set, the line behaves as if DCD is always asserted. The software carrier flag is usually turned on for local devices, and is off for lines with modems. Linux-spezifisch Für den TIOCLINUX-Ioctl, siehe console_ioctl(4). Kernel debugging #include <linux/tty.h> TIOCTTYGSTRUCT struct tty_struct *argp Die fd entsprechende tty_struct ermitteln. Dieser Befehl wurde in Linux 2.5.67 entfernt.
RÜCKGABEWERT
Der Systemaufruf ioctl(2) liefert im Erfolgsfall 0 zurück. Bei einem Fehler wird -1 zurückgegeben und errno entsprechend gesetzt.
FEHLER
EINVAL ungültiger Befehlsparameter ENOIOCTLCMD unbekannter Befehl ENOTTY ungeeigneter fd EPERM Unzureichende Berechtigung.
BEISPIEL
Die Bedingungen von DTR auf dem seriellen Port prüfen. #include <termios.h> #include <fcntl.h> #include <sys/ioctl.h> int main(void) { int fd, serial; fd = open("/dev/ttyS0", O_RDONLY); ioctl(fd, TIOCMGET, &serial); if (serial & TIOCM_DTR) puts("TIOCM_DTR ist gesetzt"); else puts("TIOCM_DTR ist nicht gesetzt"); close(fd); }
SIEHE AUCH
ioctl(2), termios(3), console_ioctl(4), pty(7)
KOLOPHON
Diese Seite ist Teil der Veröffentlichung 4.04 des Projekts Linux-man-pages. Eine Beschreibung des Projekts, Informationen, wie Fehler gemeldet werden können sowie die aktuelle Version dieser Seite finden sich unter http://www.kernel.org/doc/man-pages/.
ÜBERSETZUNG
Die deutsche Übersetzung dieser Handbuchseite wurde von Helge Kreutzmann <debian@helgefjell.de> erstellt. Diese Übersetzung ist Freie Dokumentation; lesen Sie die GNU General Public License Version 3 oder neuer bezüglich der Copyright-Bedingungen. Es wird KEINE HAFTUNG übernommen. Wenn Sie Fehler in der Übersetzung dieser Handbuchseite finden, schicken Sie bitte eine E- Mail an <debian-l10n-german@lists.debian.org>.