openpty(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

openpty(3c)

openpty(3C)              Standard C Library Functions              openpty(3C)

NAME
       openpty, login_tty, forkpty - terminal utility functions

SYNOPSIS
       #include <termios.h>

       int openpty(int *amanager, int *asubsidiary, char *name,
            struct termios *termp, struct winsize *winp);

       int login_tty(int fd);

       pid_t forkpty(int *amanager, char *name, struct termios *termp,
            struct winsize *winp);

DESCRIPTION
       The  openpty(),  login_tty(), and forkpty() functions perform manipula‐
       tions on ttys and pseudo-ttys.


       The openpty() function finds an available pseudo-tty and  returns  file
       descriptors for the manager and subsidiary in amanager and asubsidiary.
       If  name  is  non-null,  the  filename of the subsidiary is returned in
       name, a string of at least 32 characters. If  termp  is  non-null,  the
       terminal  parameters  of  the  subsidiary  will be set to the values in
       termp. If winp is non-null, the window size of the subsidiary  will  be
       set to the values in winp. The openpty() function first attempts to al‐
       locate   the   pseudo-tty   through  the  /dev/ptmx  device  using  the
       posix_openpt command. It then invokes the  grantpt(),  unlockpt(),  and
       ptsname()  functions  to  obtain  the  path of the pseudo-terminal sub‐
       sidiary. It opens the pseudo-terminal subsidiary, and attempts  to  set
       terminal  attribute  and window size of the pty subsidiary if termp and
       winp are valid. Finally, the function returns the pty manager  fd,  pty
       subsidiary,  and  pty  subsidiary name to the caller. For more informa‐
       tion, see pty, ptm and pts man pages.


       The login_tty() function prepares for a login on the tty fd, which  can
       either  be  a real tty device, or a subsidiary of the pseudo-tty as re‐
       turned by the openpty() function. The function prepares for a login  by
       creating a new session, making fd the controlling terminal for the cur‐
       rent  process,  setting  fd to be the standard input, output, and error
       streams of the current process, and closing fd.


       The forkpty() function combines the openpty(), fork(), and  login_tty()
       functions  to  create  a new process attached to a pseudo-tty. The file
       descriptor of the manager side of the pseudo-tty is returned  in  aman‐
       ager,  and  the  filename of the subsidiary in name, if it is non-null.
       The termp and winp parameters, if non-null, will determine the terminal
       attributes and window size of the subsidiary side of the  pseudo-termi‐
       nal.

RETURN VALUES
       If  a call to the openpty(), login_tty(), or forkpty() functions is not
       successful, then -1 is returned, and errno is set to indicate  the  er‐
       ror.  Otherwise,  the  openpty(), login_tty(), and the child process of
       the forkpty() functions return 0, and the parent process  of  forkpty()
       returns the process ID of the child process.

ERRORS
       The openpty() function will fail if:


       EMFILE    OPEN_MAX  file  descriptors are currently open in the calling
                 process


       ENFILE    The maximum allowable number of files are currently  open  in
                 the system


       EAGAIN    Out of pseudo-terminal resources


       EACCES    The corresponding subsidiary pseudo-terminal device could not
                 be accessed




       The login_tty() function will fail if:


       EPERM      The  calling  process  is already a process group leader, or
                  the process group ID of a process  other  than  the  calling
                  process matches the process ID of the calling process


       EBADF      The fildes argument is not a valid open file descriptor


       EMFILE     The  process  has too many files open. For more information,
                  see the getrlimit man page


       ENOLINK    The fildes argument is on a remote machine and the  link  to
                  that machine is no longer active




       The forkpty() function will fail if:


       EAGAIN    A resource control or limit on the total number of processes,
                 tasks,  or  LWPs  under  execution  by  a  single user, task,
                 project, or zone has been exceeded. This error can also occur
                 if the total amount of system memory available is temporarily
                 insufficient to duplicate this process


       ENOMEM    There is not enough swap space


       EPERM     The PRIV_PROC_FORK privilege is not asserted in the effective
                 set of the calling process



FILES
       /dev/ptmx     Manager clone device


       /dev/pts/M    Subsidiary devices (M = 0 -> N-1)



ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:

       tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE  TYPEAT‐
       TRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelSafe


SEE ALSO
       pty(4D),  pts(4D),  posix_openpt(3C),  grantpt(3C),  unlockpt(3C),  pt‐
       sname(3C), getrlimit(2)

Oracle Solaris 11.4               19 Jun 2024                      openpty(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3