mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 13:49:54 +00:00
Merge pull request #111114 from bruvzg/sigpipe_ign
Suppress SIGPIPE when writing to a pipe.
This commit is contained in:
commit
0da802cdd7
1 changed files with 10 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue