diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-05 21:17:41 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-05 21:17:41 +0100 |
commit | f2a087126c30c5c1525b8e6ba46af635e2fab2b4 (patch) | |
tree | 609bc5ff372f64925db9c09c606f5d47e1fea47e /Libraries/LibC/stdlib.cpp | |
parent | 6d1740e4be041e7f68c8e05f4f0cbcc7f91ae22b (diff) | |
download | serenity-f2a087126c30c5c1525b8e6ba46af635e2fab2b4.zip |
LibC: Add posix_openpt(), grantpt() and unlockpt()
This makes getting a pseudoterminal pair a little bit more portable.
Note that grantpt() and unlockpt() are currently no-ops, since we've
already granted the pseudoterminal slave to the calling user.
We also accept O_CLOEXEC to posix_openpt(), unlike some systems. :^)
Diffstat (limited to 'Libraries/LibC/stdlib.cpp')
-rw-r--r-- | Libraries/LibC/stdlib.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Libraries/LibC/stdlib.cpp b/Libraries/LibC/stdlib.cpp index 43b6e83ba7..925e8882e5 100644 --- a/Libraries/LibC/stdlib.cpp +++ b/Libraries/LibC/stdlib.cpp @@ -746,4 +746,26 @@ char* realpath(const char* pathname, char* buffer) errno = 0; return buffer; } + +int posix_openpt(int flags) +{ + if (flags & ~(O_RDWR | O_NOCTTY | O_CLOEXEC)) { + errno = EINVAL; + return -1; + } + + return open("/dev/ptmx", flags); +} + +int grantpt(int fd) +{ + (void)fd; + return 0; +} + +int unlockpt(int fd) +{ + (void)fd; + return 0; +} } |