You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Suppress SIGPIPE when writing to a pipe.
This commit is contained in:
@@ -41,6 +41,11 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
#include <csignal>
|
||||
|
||||
#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 {
|
||||
|
||||
Reference in New Issue
Block a user