Provided by: manpages-ru-dev_4.21.0-2_all bug

ИМЯ

       openpty, login_tty, forkpty - функции для работы с терминалом

LIBRARY

       System utilities library (libutil, -lutil)

СИНТАКСИС

       #include <pty.h>

       int openpty(int *amaster, int *aslave, char *name,
                     const struct termios *termp,
                     const struct winsize *winp);
       pid_t forkpty(int *amaster, char *name,
                     const struct termios *termp,
                     const struct winsize *winp);

       #include <utmp.h>

       int login_tty(int fd);

ОПИСАНИЕ

       Функция  openpty()  ищет  доступный  псевдотерминал и возвращает файловые дескрипторы для его основного и
       подчинённого устройств в amaster и aslave. Если name не равно NULL, то имя файла подчинённого  устройства
       возвращается  в  name.  Если  termp  не  равно NULL, то параметры терминала подчинённого устройства будут
       установлены в значения, указанные в  termp.  Если  winp  не  равно  NULL,  то  размер  окна  подчинённого
       устройства будет установлен согласно значениям, указанным в winp.

       The  login_tty()   function  prepares  for  a login on the terminal referred to by the file descriptor fd
       (which may be a real terminal device, or the slave of a pseudoterminal  as  returned  by  openpty())   by
       creating  a new session, making fd the controlling terminal for the calling process, setting fd to be the
       standard input, output, and error streams of the current process, and closing fd.

       The forkpty()  function combines openpty(), fork(2), and login_tty()  to create a new  process  operating
       in  a  pseudoterminal.   A  file descriptor referring to master side of the pseudoterminal is returned in
       amaster.  If name is not NULL, the buffer it points to is used to return the filename of the slave.   The
       termp  and  winp  arguments,  if  not NULL, will determine the terminal attributes and window size of the
       slave side of the pseudoterminal.

ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ

       Если вызов openpty(), login_tty() или forkpty()  завершается  с  ошибкой,  то  возвращается  -1  и  errno
       указывает  на  тип  ошибки.  Иначе,  openpty(),  login_tty() и дочерний процесс forkpty() возвращают 0, и
       родительский процесс forkpty() возвращает ID дочернего процесса.

ОШИБКИ

       Вызов openpty() завершается ошибкой если:

       ENOENT Нет доступных терминалов.

       Завершается ошибкой функция login_tty(), если ioctl(2)  не  может  назначить  fd  управляющему  терминалу
       вызываемого процесса.

       Завершается ошибкой функция forkpty(), если не сработает хотя бы одна из функций openpty() или fork(2).

АТРИБУТЫ

       Описание терминов данного раздела смотрите в attributes(7).
       ┌───────────────────────────────────────────────────────┬──────────────────────┬────────────────────────┐
       │ ИнтерфейсАтрибутЗначение               │
       ├───────────────────────────────────────────────────────┼──────────────────────┼────────────────────────┤
       │ forkpty(), openpty()                                  │ Безвредность в нитях │ MT-Safe locale         │
       ├───────────────────────────────────────────────────────┼──────────────────────┼────────────────────────┤
       │ login_tty()                                           │ Безвредность в нитях │ MT-Unsafe race:ttyname │
       └───────────────────────────────────────────────────────┴──────────────────────┴────────────────────────┘

СТАНДАРТЫ

       Данные функции BSD есть в glibc. Они не стандартизированы в POSIX.

ЗАМЕЧАНИЯ

       Модификаторы const были добавлены в аргументы указателей на структуры openpty() и forkpty() в glibc 2.8.

       Before  glibc  2.0.92,  openpty()   returns  file  descriptors for a BSD pseudoterminal pair; since glibc
       2.0.92, it first attempts to open a UNIX 98  pseudoterminal  pair,  and  falls  back  to  opening  a  BSD
       pseudoterminal pair if that fails.

ДЕФЕКТЫ

       Невозможно  определить  сколько  места должно быть зарезервировано для name. Поэтому, вызов openpty() или
       forkpty() со значением name не равным NULL может быть небезопасен.

СМ. ТАКЖЕ

       fork(2), ttyname(3), pty(7)

ПЕРЕВОД

       Русский перевод  этой  страницы  руководства  был  сделан  Azamat  Hackimov  <azamat.hackimov@gmail.com>,
       Konstantin   Shvaykovskiy   <kot.shv@gmail.com>,   Yuri   Kozlov   <yuray@komyakino.ru>   и  Иван  Павлов
       <pavia00@gmail.com>

       Этот перевод является бесплатной документацией; прочитайте Стандартную общественную лицензию GNU версии 3
       или более позднюю, чтобы узнать об условиях авторского права. Мы не несем НИКАКОЙ ОТВЕТСТВЕННОСТИ.

       Если вы обнаружите ошибки в переводе этой страницы руководства, пожалуйста, отправьте электронное  письмо
       на man-pages-ru-talks@lists.sourceforge.net.

Linux man-pages 6.03                           15 декабря 2022 г.                                     openpty(3)