aboutsummaryrefslogtreecommitdiff
path: root/src/common/platform/unix/UnixPipe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/platform/unix/UnixPipe.cpp')
-rw-r--r--src/common/platform/unix/UnixPipe.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/platform/unix/UnixPipe.cpp b/src/common/platform/unix/UnixPipe.cpp
index 8393f022..4d081d5e 100644
--- a/src/common/platform/unix/UnixPipe.cpp
+++ b/src/common/platform/unix/UnixPipe.cpp
@@ -2,14 +2,23 @@
#include "cru/common/Exception.h"
#include "cru/common/log/Logger.h"
+#include <fcntl.h>
+#include <sys/fcntl.h>
#include <unistd.h>
namespace cru::platform::unix {
-UnixPipe::UnixPipe(Usage usage) : usage_(usage) {
+UnixPipe::UnixPipe(Usage usage, UnixPipeFlag flags)
+ : usage_(usage), flags_(flags) {
int fds[2];
if (pipe(fds) != 0) {
throw ErrnoException(u"Failed to create unix pipe.");
}
+
+ if (flags & UnixPipeFlags::NonBlock) {
+ fcntl(fds[0], F_SETFL, O_NONBLOCK);
+ fcntl(fds[1], F_SETFL, O_NONBLOCK);
+ }
+
read_fd_ = fds[0];
write_fd_ = fds[1];
}