GETPTY(3) GETPTY(3)
_getpty, mkpts - get a PTY or Pseudo-TTY
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
char *_getpty(int *fildes, int oflag, mode_t mode,
int nofork);
This function finds and allocates a pair of devices making a pseudo-TTY,
described in pty(7M).
If filedes is not null, then the file descriptor for the master or
controlling side of the pty is stored through the pointer. If
successful, a pointer to an internal, static area containing the name of
the slave device node is returned. The file descriptor is opened with
the value oflag, constructed as described in open(2).
The access bits of the slave device node are set to mode. The owner of
the slave device is set to the real UID of the caller, and the GID is
reset.
If nofork is 0 and the process does not have effective UID 0, then this
function may execute /usr/sbin/mkpts to change the owner and permissions
of the node for the slave device.
The slave device file in /dev will be created if it does not already
exist.
This function may also use the facilities described in getgrent(3C) to
set the group of the slave device node.
chmod(2), chown(2), getgrent(3C), open(2), pty(7M), tty(1), tty(7)
A returned value of 0 indicates failure, with errno indicating the nature
of the problem.
When _getpty(3) uses /usr/sbin/mkpts, it waits for it to finish with
waitpid(2). This requires that the caller not have set SIGCLD to
SIG_IGN. Instead, _getpty(3) should save and restore the signal handler.
See wait(2) and signal(2). The nofork argument can used to avoid
undesirable forks.
PPPPaaaaggggeeee 1111 [ Back ]
|