The forkpty()
function shall find and open a pseudo-terminal device pair in the
same manner as the openpty()
function.
If a pseudo-terminal is available,
forkpty
shall create a new process in the same manner as the fork()
function, and prepares the new process for login in the same manner as
login_tty()
.
If termp is not null, it shall refer to a termios structure that shall be used to initialize the characteristics of the slave device. If winp is not null, it shall refer to a winsize structure used to initialize the window size of the slave device.
On success, the parent process shall return the process id of the child, and the child shall return 0. On error, no new process shall be created, -1 shall be returned, and errno shall be set appropriately. On success, the parent process shall receive the file descriptor of the master side of the pseudo-terminal in the location referenced by amaster, and, if name is not NULL, the filename of the slave device in name.