Kernel: Fix EAGAIN on hungup pipe
This commit is contained in:
parent
b46337d376
commit
8c29036fbf
|
@ -429,6 +429,8 @@ namespace Kernel
|
||||||
size_t nread;
|
size_t nread;
|
||||||
{
|
{
|
||||||
LockGuard _(inode->m_mutex);
|
LockGuard _(inode->m_mutex);
|
||||||
|
if (!inode->can_read() && inode->has_hungup())
|
||||||
|
return 0;
|
||||||
if (is_nonblock && !inode->can_read())
|
if (is_nonblock && !inode->can_read())
|
||||||
return BAN::Error::from_errno(EAGAIN);
|
return BAN::Error::from_errno(EAGAIN);
|
||||||
nread = TRY(inode->read(offset, buffer));
|
nread = TRY(inode->read(offset, buffer));
|
||||||
|
@ -464,6 +466,11 @@ namespace Kernel
|
||||||
size_t nwrite;
|
size_t nwrite;
|
||||||
{
|
{
|
||||||
LockGuard _(inode->m_mutex);
|
LockGuard _(inode->m_mutex);
|
||||||
|
if (inode->has_error())
|
||||||
|
{
|
||||||
|
Thread::current().add_signal(SIGPIPE);
|
||||||
|
return BAN::Error::from_errno(EPIPE);
|
||||||
|
}
|
||||||
if (is_nonblock && !inode->can_write())
|
if (is_nonblock && !inode->can_write())
|
||||||
return BAN::Error::from_errno(EAGAIN);
|
return BAN::Error::from_errno(EAGAIN);
|
||||||
nwrite = TRY(inode->write(offset, buffer));
|
nwrite = TRY(inode->write(offset, buffer));
|
||||||
|
|
Loading…
Reference in New Issue