diff options
author | pommicket <pommicket@gmail.com> | 2022-02-20 13:18:21 -0800 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-02-20 13:18:21 -0800 |
commit | 9bc8a11afeed3569736b89754012e3ca22ee10f6 (patch) | |
tree | 5f0ec0d5c05f879b1ee86adfa654ed3ef2178d5f /05/musl-0.6.0/src/misc/pty.c | |
parent | 0f97a589b800bdb71dda05984192f0f66a52edaa (diff) |
conclusion
Diffstat (limited to '05/musl-0.6.0/src/misc/pty.c')
-rw-r--r-- | 05/musl-0.6.0/src/misc/pty.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/05/musl-0.6.0/src/misc/pty.c b/05/musl-0.6.0/src/misc/pty.c new file mode 100644 index 0000000..0d25a83 --- /dev/null +++ b/05/musl-0.6.0/src/misc/pty.c @@ -0,0 +1,35 @@ +#include <stdlib.h> +#include <sys/ioctl.h> +#include <stdio.h> +#include <fcntl.h> + +int posix_openpt(int flags) +{ + return open("/dev/ptmx", flags); +} + +int grantpt(int fd) +{ + return 0; +} + +int unlockpt(int fd) +{ + int unlock = 0; + return ioctl(fd, TIOCSPTLCK, &unlock); +} + +char *ptsname(int fd) +{ + static char buf[9 + sizeof(int)*3 + 1]; + char *s = buf+sizeof(buf)-1; + int pty; + if (ioctl (fd, TIOCGPTN, &pty)) + return NULL; + if (pty) for (; pty; pty/=10) *--s = '0' + pty%10; + else *--s = '0'; + s -= 9; + s[0] = '/'; s[1] = 'd'; s[2] = 'e'; s[3] = 'v'; + s[4] = '/'; s[5] = 'p'; s[6] = 't'; s[7] = 's'; s[8] = '/'; + return s; +} |