.\" -*- coding: UTF-8 -*- .\" Copyright (C) 2005 Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH PTY 7 "13 августа 2020 г." Linux "Руководство программиста Linux" .SH ИМЯ pty \- интерфейсы псевдо\-терминалов .SH ОПИСАНИЕ A pseudoterminal (sometimes abbreviated "pty") is a pair of virtual character devices that provide a bidirectional communication channel. One end of the channel is called the \fImaster\fP; the other end is called the \fIslave\fP. .PP The slave end of the pseudoterminal provides an interface that behaves exactly like a classical terminal. A process that expects to be connected to a terminal, can open the slave end of a pseudoterminal and then be driven by a program that has opened the master end. Anything that is written on the master end is provided to the process on the slave end as though it was input typed on a terminal. For example, writing the interrupt character (usually control\-C) to the master device would cause an interrupt signal (\fBSIGINT\fP) to be generated for the foreground process group that is connected to the slave. Conversely, anything that is written to the slave end of the pseudoterminal can be read by the process that is connected to the master end. .PP Поток данных между основным и подчинённым концом обрабатывается асинхронно, почти как поток с физического терминала. Данные, записываемые в подчинённый конец, будут доступны без промедления, но могут быть недоступны немедленно. Схожим образом, есть маленькая задержка обработки между записью в основной конец и когда эти данные станут видимы на подчинённом конце. .PP Исторически существует два программных интерфейса для взаимодействия с псевдо\-терминалами: BSD и System V. В SUSv1 стандартизирован программный интерфейс, основанный на программном интерфейсе System V, который должен применяться во всех новых программах, использующих псевдо\-терминалы. .PP Linux provides both BSD\-style and (standardized) System V\-style pseudoterminals. System V\-style terminals are commonly called UNIX 98 pseudoterminals on Linux systems. .PP Since kernel 2.6.4, BSD\-style pseudoterminals are considered deprecated: support can be disabled when building the kernel by disabling the \fBCONFIG_LEGACY_PTYS\fP option. (Starting with Linux 2.6.30, that option is disabled by default in the mainline kernel.) UNIX 98 pseudoterminals should be used in new applications. .SS "Псевдо\-терминалы UNIX 98" Незадействованный основной псевдо\-терминал UNIX 98 открывается вызовом \fBposix_openpt\fP(3) (эта функция открывает основное клонирующее устройство, \fI/dev/ptmx\fP; смотрите \fBpts\fP(4)). После выполнения специальной программной инициализации (с помощью \fBgrantpt\fP(3) изменяется владелец и права на подчинённое устройство и с помощью \fBunlockpt\fP(3) разблокируется подчинённое устройство), соответствующее подчинённое устройство можно открыть, передав имя, полученное от \fBptsname\fP(3), в вызов \fBopen\fP(2). .PP Ядро Linux задаёт ограничение на количество доступных псевдо\-терминалов UNIX 98. В ядрах до версии 2.6.3 включительно, это ограничение настраивалось при компиляции ядра (\fBCONFIG_UNIX98_PTYS\fP), и разрешалось 2048 псевдо\-терминалов (по умолчанию 256). Начиная с версии 2.6.4, ограничение динамически настраивается через \fI/proc/sys/kernel/pty/max\fP, а в файле \fI/proc/sys/kernel/pty/nr\fP хранится количество уже используемых псевдо\-терминалов. Подробности об этих двух файлах смотрите в \fBproc\fP(5). .SS "Псевдо\-терминалы BSD" Псевдо\-терминалы в стиле BSD предоставляются в виде заранее созданных пар, с именами вида \fI/dev/ptyXY\fP (основной) и \fI/dev/ttyXY\fP (подчинённый), где X это буква из 16\-символьного набора [p\-za\-e], а Y это буква из 16\-символьного набора [0\-9a\-f] (точный диапазон символов этих наборов отличается в разных реализациях UNIX). Например, \fI/dev/ptyp1\fP и \fI/dev/ttyp1\fP составляют псевдо\-терминальную пару BSD. Процесс находит неиспользуемую псевдо\-терминальную пару пробуя вызывать \fBopen\fP(2) с каждым основным псевдо\-терминалом, пока вызов не выполнится успешно. Затем может быть открыт соответствующий подчинённый псевдо\-терминал (подставив «tty» вместо «pty» имени основного конца). .SH ФАЙЛЫ .TP \fI/dev/ptmx\fP основное клонирующее устройство UNIX 98 .TP \fI/dev/pts/*\fP подчинённые устройства UNIX 98 .TP \fI/dev/pty[p\-za\-e][0\-9a\-f]\fP основные устройства BSD .TP \fI/dev/tty[p\-za\-e][0\-9a\-f]\fP подчинённые устройства BSD .SH ЗАМЕЧАНИЯ Pseudoterminals are used by applications such as network login services (\fBssh\fP(1), \fBrlogin\fP(1), \fBtelnet\fP(1)), terminal emulators such as \fBxterm\fP(1), \fBscript\fP(1), \fBscreen\fP(1), \fBtmux\fP(1), \fBunbuffer\fP(1), and \fBexpect\fP(1). .PP Описание запроса \fBTIOCPKT\fP \fBioctl\fP(2), который управляет пакетным режимом, можно найти в \fBioctl_tty\fP(2). .PP Вызовы \fBioctl\fP(2) для BSD \fBTIOCSTOP\fP, \fBTIOCSTART\fP, \fBTIOCUCNTL\fP и \fBTIOCREMOTE\fP не реализованы в Linux. .SH "СМ. ТАКЖЕ" \fBioctl_tty\fP(2), \fBselect\fP(2), \fBsetsid\fP(2), \fBforkpty\fP(3), \fBopenpty\fP(3), \fBtermios\fP(3), \fBpts\fP(4), \fBtty\fP(4) .SH ЗАМЕЧАНИЯ Эта страница является частью проекта Linux \fIman\-pages\fP версии 5.10. Описание проекта, информацию об ошибках и последнюю версию этой страницы можно найти по адресу \%https://www.kernel.org/doc/man\-pages/. .PP .SH ПЕРЕВОД Русский перевод этой страницы руководства был сделан Alexey, Azamat Hackimov , kogamatranslator49 , Kogan, Max Is , Yuri Kozlov и Иван Павлов . .PP Этот перевод является бесплатной документацией; прочитайте .UR https://www.gnu.org/licenses/gpl-3.0.html Стандартную общественную лицензию GNU версии 3 .UE или более позднюю, чтобы узнать об условиях авторского права. Мы не несем НИКАКОЙ ОТВЕТСТВЕННОСТИ. .PP Если вы обнаружите ошибки в переводе этой страницы руководства, пожалуйста, отправьте электронное письмо на .MT man-pages-ru-talks@lists.sourceforge.net .ME .