openpty - library call to obtain a pty
#include <libutil.h> int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
Openpty tries to obtain pty file descriptors by opening /dev/ttypX and /dev/ptypX, setting *amaster and *aslave to these fd's, changing ownership of the slave pty to the current process, and making it only group-writable by group tty.