diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-24 23:25:03 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-24 23:25:03 +0100 |
commit | 1749442a1cb839f217a86227bd6f6494db9bde92 (patch) | |
tree | 1dde1960fdbe6a935713c57fdc79f8ed2cd269ee /Userland | |
parent | 748c8b4879d48e1e15f4d3875dcab2ee0c345cd4 (diff) | |
download | serenity-1749442a1cb839f217a86227bd6f6494db9bde92.zip |
Terminal: Use LibCore syscall wrapper for ptsname()
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/Terminal/main.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 188730ed6e..a99495500d 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -47,10 +47,8 @@ #include <sys/wait.h> #include <unistd.h> -static void utmp_update(const char* tty, pid_t pid, bool create) +static void utmp_update(String const& tty, pid_t pid, bool create) { - if (!tty) - return; int utmpupdate_pid = fork(); if (utmpupdate_pid < 0) { perror("fork"); @@ -62,7 +60,7 @@ static void utmp_update(const char* tty, pid_t pid, bool create) // including the heap! So resort to low-level APIs char pid_str[32]; snprintf(pid_str, sizeof(pid_str), "%d", pid); - execl("/bin/utmpupdate", "/bin/utmpupdate", "-f", "Terminal", "-p", pid_str, (create ? "-c" : "-d"), tty, nullptr); + execl("/bin/utmpupdate", "/bin/utmpupdate", "-f", "Terminal", "-p", pid_str, (create ? "-c" : "-d"), tty.characters(), nullptr); } else { wait_again: int status = 0; @@ -296,8 +294,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) VERIFY_NOT_REACHED(); } - auto* pts_name = ptsname(ptm_fd); - utmp_update(pts_name, shell_pid, true); + auto ptsname = TRY(Core::System::ptsname(ptm_fd)); + utmp_update(ptsname, shell_pid, true); auto app_icon = GUI::Icon::default_icon("app-terminal"); @@ -431,6 +429,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) window->show(); int result = app->exec(); dbgln("Exiting terminal, updating utmp"); - utmp_update(pts_name, 0, false); + utmp_update(ptsname, 0, false); return result; } |