mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
This is dirty but pretty cool! If we have a pending, unmasked signal for a process that's blocked inside the kernel, we set up alternate stacks for that process and unblock it to execute the signal handler. A slightly different return trampoline is used here: since we need to get back into the kernel, a dedicated syscall is used (sys$sigreturn.) This restores the TSS contents of the process to the state it was in while we were originally blocking in the kernel. NOTE: There's currently only one "kernel resume TSS" so signal nesting definitely won't work.
34 lines
602 B
C++
34 lines
602 B
C++
#include "FullDevice.h"
|
|
#include "Limits.h"
|
|
#include <LibC/errno_numbers.h>
|
|
#include <AK/StdLib.h>
|
|
#include <AK/kstdio.h>
|
|
|
|
FullDevice::FullDevice()
|
|
: CharacterDevice(1, 7)
|
|
{
|
|
}
|
|
|
|
FullDevice::~FullDevice()
|
|
{
|
|
}
|
|
|
|
bool FullDevice::hasDataAvailableForRead() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
Unix::ssize_t FullDevice::read(byte* buffer, Unix::size_t bufferSize)
|
|
{
|
|
Unix::size_t count = min(GoodBufferSize, bufferSize);
|
|
memset(buffer, 0, count);
|
|
return count;
|
|
}
|
|
|
|
Unix::ssize_t FullDevice::write(const byte*, Unix::size_t bufferSize)
|
|
{
|
|
if (bufferSize == 0)
|
|
return 0;
|
|
return -ENOSPC;
|
|
}
|
|
|