mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 02:09:24 +00:00
AK: Enable Core::File to switch blocking-mode during use
This closely mirrors Socket::set_blocking. Note that it does not make sense to make this a virtual method on a base class, since SeekableStream and FixedMemoryStream cannot possible be anything except than blocking.
This commit is contained in:
parent
6f8c2dc322
commit
62ebb78433
Notes:
sideshowbarker
2024-07-17 11:06:06 +09:00
Author: https://github.com/BenWiederhake
Commit: 62ebb78433
Pull-request: https://github.com/SerenityOS/serenity/pull/18965
Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 16 additions and 0 deletions
|
@ -182,4 +182,13 @@ ErrorOr<void> File::truncate(size_t length)
|
|||
return System::ftruncate(m_fd, length);
|
||||
}
|
||||
|
||||
ErrorOr<void> File::set_blocking(bool enabled)
|
||||
{
|
||||
// NOTE: This works fine on Serenity, but some systems out there don't support changing the blocking state of certain POSIX objects (message queues, pipes, etc) after their creation.
|
||||
// Therefore, this method shouldn't be used in Lagom.
|
||||
// https://github.com/SerenityOS/serenity/pull/18965#discussion_r1207951840
|
||||
int value = enabled ? 0 : 1;
|
||||
return System::ioctl(fd(), FIONBIO, &value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue