diff options
author | Tom <tomut@yahoo.com> | 2020-09-17 13:51:09 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-03 22:12:19 +0100 |
commit | f98ca35b83d521377d4bce5927fdcb4a764ac02e (patch) | |
tree | 1fe252ef4d572a3dede621052766fa96ebc4da9d /Kernel/TTY/PTYMultiplexer.cpp | |
parent | b36f57e5705a9db89e267608f9a1f8d9f8f640b8 (diff) | |
download | serenity-f98ca35b83d521377d4bce5927fdcb4a764ac02e.zip |
Kernel: Improve ProcFS behavior in low memory conditions
When ProcFS could no longer allocate KBuffer objects to serve calls to
read, it would just return 0, indicating EOF. This then triggered
parsing errors because code assumed it read the file.
Because read isn't supposed to return ENOMEM, change ProcFS to populate
the file data upon file open or seek to the beginning. This also means
that calls to open can now return ENOMEM if needed. This allows the
caller to either be able to successfully open the file and read it, or
fail to open it in the first place.
Diffstat (limited to 'Kernel/TTY/PTYMultiplexer.cpp')
-rw-r--r-- | Kernel/TTY/PTYMultiplexer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/TTY/PTYMultiplexer.cpp b/Kernel/TTY/PTYMultiplexer.cpp index e4b7394a9b..7a9789c544 100644 --- a/Kernel/TTY/PTYMultiplexer.cpp +++ b/Kernel/TTY/PTYMultiplexer.cpp @@ -66,8 +66,10 @@ KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options) dbg() << "PTYMultiplexer::open: Vending master " << master->index(); #endif auto description = FileDescription::create(move(master)); - description->set_rw_mode(options); - description->set_file_flags(options); + if (!description.is_error()) { + description.value()->set_rw_mode(options); + description.value()->set_file_flags(options); + } return description; } |