1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

FIFO: Raise SIGPIPE in processes that write() to a broken pipe.

This commit is contained in:
Andreas Kling 2019-06-06 10:54:26 +02:00
parent abb3643d88
commit e4cfa9a686

View file

@ -1,6 +1,8 @@
#include <Kernel/FileSystem/FIFO.h>
#include <Kernel/FileSystem/FileDescriptor.h>
#include <Kernel/Lock.h>
#include <Kernel/Process.h>
#include <Kernel/Thread.h>
#include <AK/StdLibExtras.h>
#include <AK/HashTable.h>
@ -107,8 +109,10 @@ ssize_t FIFO::read(FileDescriptor&, byte* buffer, ssize_t size)
ssize_t FIFO::write(FileDescriptor&, const byte* buffer, ssize_t size)
{
if (!m_readers)
if (!m_readers) {
current->process().send_signal(SIGPIPE, &current->process());
return -EPIPE;
}
#ifdef FIFO_DEBUG
dbgprintf("fifo: write(%p, %u)\n", buffer, size);
#endif