Most modern systems use Unix 98 style pseudo terminals. To open a master terminal and configure the save in C, do something like:
Code:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define _XOPEN_SOURCE
#include <stdlib.h>
int main(int argc, char **argv) {
char *slavename;
int masterfd;
masterfd = open("/dev/ptmx", O_RDWR);
grantpt(masterfd);
unlockpt(masterfd);
slavename = ptsname(masterfd);
...
}
The name of the slave file will be in `slavename' and can be opened with all call to open, like:
Code:
open(slavename, O_RDWR)
If your system does not have a `/dev/ptmx', you probably have BSD style pseudo terminals. See the BSD pseudo terminal section in
pty(7).