diff options
Diffstat (limited to 'usr/klibc/pty.c')
-rw-r--r-- | usr/klibc/pty.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/usr/klibc/pty.c b/usr/klibc/pty.c new file mode 100644 index 0000000..7fcb2ba --- /dev/null +++ b/usr/klibc/pty.c @@ -0,0 +1,31 @@ +/* + * pty.c + * + * Basic Unix98 PTY functionality; assumes devpts mounted on /dev/pts + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <termios.h> +#include <sys/ioctl.h> + +char *ptsname(int fd) +{ + static char buffer[32]; /* Big enough to hold even a 64-bit pts no */ + unsigned int ptyno; + + if (ioctl(fd, TIOCGPTN, &ptyno)) + return NULL; + + snprintf(buffer, sizeof buffer, "/dev/pts/%u", ptyno); + + return buffer; +} + +int unlockpt(int fd) +{ + int unlock = 0; + + return ioctl(fd, TIOCSPTLCK, &unlock); +} |