mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 04:35:41 +03:00
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.
This commit is contained in:
parent
2ecc608dea
commit
77add584fa
Notes:
sideshowbarker
2024-07-19 17:06:55 +09:00
Author: https://github.com/tsymalla 🔰 Commit: https://github.com/SerenityOS/serenity/commit/77add584fa8 Pull-request: https://github.com/SerenityOS/serenity/pull/13352 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/supercomputer7 ✅
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user