]>
Commit | Line | Data |
---|---|---|
a41a0e28 GKH |
1 | /* |
2 | * pty.c | |
3 | * | |
73028bc3 | 4 | * Basic Unix98 PTY functionality; assumes devpts mounted on /dev/pts |
a41a0e28 GKH |
5 | */ |
6 | ||
7 | #include <stdio.h> | |
8 | #include <stdlib.h> | |
9 | #include <unistd.h> | |
10 | #include <termios.h> | |
11 | #include <sys/ioctl.h> | |
12 | ||
13 | char *ptsname(int fd) | |
14 | { | |
15 | static char buffer[32]; /* Big enough to hold even a 64-bit pts no */ | |
16 | unsigned int ptyno; | |
17 | ||
18 | if ( ioctl(fd, TIOCGPTN, &ptyno) ) | |
19 | return NULL; | |
20 | ||
21 | snprintf(buffer, sizeof buffer, "/dev/pts/%u", ptyno); | |
22 | ||
23 | return buffer; | |
24 | } | |
25 | ||
26 | int unlockpt(int fd) | |
27 | { | |
28 | int unlock = 0; | |
29 | ||
30 | return ioctl(fd, TIOCSPTLCK, &unlock); | |
31 | } |