diff options
author | Thomas Symalla <thomas.symalla@dl-studios.info> | 2022-03-30 10:22:27 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-02 21:49:16 +0200 |
commit | 77add584fa8a69b262738f0b1a5697fbde306ae4 (patch) | |
tree | 56ec6db41923ec9fb3e63e87954dc59fab542021 /Userland | |
parent | 2ecc608dea3dbe201bb85c89edeeaefd59826188 (diff) | |
download | serenity-77add584fa8a69b262738f0b1a5697fbde306ae4.zip |
Userland: Fix crash when inputting non-tty device into ps
This PR aims to fix #13299 by avoiding assertion failure
while trying to determine the pseudo tty when inputting
any non-tty device device into ps.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/ps.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Utilities/ps.cpp b/Userland/Utilities/ps.cpp index 7b6f934fc2..a7bea5933d 100644 --- a/Userland/Utilities/ps.cpp +++ b/Userland/Utilities/ps.cpp @@ -20,15 +20,18 @@ static ErrorOr<String> determine_tty_pseudo_name() perror("fstat"); return Error::from_errno(saved_errno); } + int tty_device_major = major(tty_stat.st_rdev); int tty_device_minor = minor(tty_stat.st_rdev); + if (tty_device_major == 201) { return String::formatted("pts:{}", tty_device_minor); } + if (tty_device_major == 4) { return String::formatted("tty:{}", tty_device_minor); } - VERIFY_NOT_REACHED(); + return "n/a"; } ErrorOr<int> serenity_main(Main::Arguments arguments) |