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 /DevTools/HackStudio/TerminalWrapper.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 'DevTools/HackStudio/TerminalWrapper.cpp')
-rw-r--r-- | DevTools/HackStudio/TerminalWrapper.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/DevTools/HackStudio/TerminalWrapper.cpp b/DevTools/HackStudio/TerminalWrapper.cpp index e7c5e192f9..89106673ca 100644 --- a/DevTools/HackStudio/TerminalWrapper.cpp +++ b/DevTools/HackStudio/TerminalWrapper.cpp @@ -52,9 +52,17 @@ void TerminalWrapper::run_command(const String& command) return; } - int ptm_fd = open("/dev/ptmx", O_RDWR | O_CLOEXEC); + int ptm_fd = posix_openpt(O_RDWR | O_CLOEXEC); if (ptm_fd < 0) { - perror("open(ptmx)"); + perror("posix_openpt"); + ASSERT_NOT_REACHED(); + } + if (grantpt(ptm_fd) < 0) { + perror("grantpt"); + ASSERT_NOT_REACHED(); + } + if (unlockpt(ptm_fd) < 0) { + perror("unlockpt"); ASSERT_NOT_REACHED(); } |