forkpty man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

PTY(3)			 BSD Library Functions Manual			PTY(3)

NAME
     openpty, forkpty — auxiliary functions to obtain a pseudo-terminal

LIBRARY
     System Utilities Library (libutil, -lutil)

SYNOPSIS
     #include <sys/types.h>
     #include <sys/ioctl.h>
     #include <termios.h>
     #include <libutil.h>

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

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

DESCRIPTION
     The function openpty() attempts to obtain the next available pseudo-ter‐
     minal from the system (see pty(4)).  If it successfully finds one, it
     subsequently tries to change the ownership of the slave device to the
     real UID of the current process, the group membership to the group “tty”
     (if such a group exists in the system), the access permissions for read‐
     ing and writing by the owner, and for writing by the group, and to inval‐
     idate any current use of the line by calling revoke(2).

     If the argument name is not NULL, openpty() copies the pathname of the
     slave pty to this area.  The caller is responsible for allocating the
     required space in this array.

     If the arguments termp or winp are not NULL, openpty() initializes the
     termios and window size settings from the structures these arguments
     point to, respectively.

     Upon return, the open file descriptors for the master and slave side of
     the pty are returned in the locations pointed to by amaster and aslave,
     respectively.

     Forkpty() first calls openpty() to obtain the next available pseudo-ter‐
     minal from the system.  Upon success, it forks off a new process.	In the
     child process, it closes the descriptor for the master side of the pty,
     and calls login_tty(3) for the slave pty.	In the parent process, it
     closes the descriptor for the slave side of the pty.  The arguments
     amaster, name, termp, and winp have the same meaning as described for
     openpty().

RETURN VALUES
     Openpty() returns 0 on success, or -1 on failure.

     Forkpty() returns -1 on failure, 0 in the slave process, and the process
     ID of the slave process in the parent process.

ERRORS
     On failure, openpty() will set the global variable errno to ENOENT.

     In addition to this, forkpty() may set it to any value as described for
     fork(2).

SEE ALSO
     chmod(2), chown(2), fork(2), getuid(2), open(2), revoke(2), login_tty(3),
     pty(4), termios(4), group(5)

BUGS
     The calling process must have an effective UID of super-user in order to
     perform all the intended actions.	No notification will occur if
     openpty() or forkpty() failed to proceed with one of the described steps,
     as long as they could at least allocate the pty at all (and create the
     new process in the case of forkpty()).

BSD			       December 29, 1996			   BSD
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net