diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-15 06:30:19 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-15 06:30:19 +0100 |
commit | 2f74c2f43009723c996f508f423eab3013b47792 (patch) | |
tree | c63ab495172eec96867ff28ffcffb5fbcbca0c98 /LibC/stdlib.cpp | |
parent | ecb4ab0943530794fb00a0a6e2a82e3e94e2f9a3 (diff) | |
download | serenity-2f74c2f43009723c996f508f423eab3013b47792.zip |
Add basic PTY support.
For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123]
Use this in the Terminal to open a pty pair and spawn a shell.
Diffstat (limited to 'LibC/stdlib.cpp')
-rw-r--r-- | LibC/stdlib.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp index deceb9f4e6..2c11843ef7 100644 --- a/LibC/stdlib.cpp +++ b/LibC/stdlib.cpp @@ -5,8 +5,10 @@ #include <string.h> #include <alloca.h> #include <assert.h> +#include <errno.h> #include <AK/Assertions.h> #include <AK/Types.h> +#include <Kernel/Syscall.h> extern "C" { @@ -215,6 +217,19 @@ long atol(const char* str) return atoi(str); } +static char ptsname_buf[32]; +char* ptsname(int fd) +{ + if (ptsname_r(fd, ptsname_buf, sizeof(ptsname_buf)) < 0) + return nullptr; + return ptsname_buf; +} + +int ptsname_r(int fd, char* buffer, size_t size) +{ + int rc = syscall(SC_ptsname_r, fd, buffer, size); + __RETURN_WITH_ERRNO(rc, rc, -1); +} static unsigned long s_next_rand = 1; |