diff --git a/drivers/unix/file_access_unix_pipe.cpp b/drivers/unix/file_access_unix_pipe.cpp index b4f3cbd56d6..e808c5ded23 100644 --- a/drivers/unix/file_access_unix_pipe.cpp +++ b/drivers/unix/file_access_unix_pipe.cpp @@ -41,6 +41,11 @@ #include #include #include +#include + +#ifndef sighandler_t +typedef typeof(void(int)) *sighandler_t; +#endif Error FileAccessUnixPipe::open_existing(int p_rfd, int p_wfd, bool p_blocking) { // Open pipe using handles created by pipe(fd) call in the OS.execute_with_pipe. @@ -165,7 +170,11 @@ bool FileAccessUnixPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) { ERR_FAIL_COND_V_MSG(fd[1] < 0, false, "Pipe must be opened before use."); ERR_FAIL_COND_V(!p_src && p_length > 0, false); - if (::write(fd[1], p_src, p_length) != (ssize_t)p_length) { + sighandler_t sig_pipe = signal(SIGPIPE, SIG_IGN); + ssize_t ret = ::write(fd[1], p_src, p_length); + signal(SIGPIPE, sig_pipe); + + if (ret != (ssize_t)p_length) { last_error = ERR_FILE_CANT_WRITE; return false; } else {