summaryrefslogtreecommitdiff
path: root/process.cpp
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2021-10-16 11:28:38 +0200
committerTom Smeding <tom@tomsmeding.com>2021-10-16 11:28:38 +0200
commit006f8b49d9ebe1ca334b934d0a127c0029300871 (patch)
treefe973fdecedb6f43fccbd8ffb70a5a82f51d59f3 /process.cpp
parentc01700906812f949c9088709b6c34307fbf63338 (diff)
'writemaybe' command to allow broken pipe errors
Diffstat (limited to 'process.cpp')
-rw-r--r--process.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/process.cpp b/process.cpp
index 6f1ec92..6adc417 100644
--- a/process.cpp
+++ b/process.cpp
@@ -131,7 +131,7 @@ void Process::unStop() {
if (pid != -1) kill(pid, SIGCONT);
}
-bool Process::writeLine(const string_view line) {
+bool Process::writeLine(const string_view line, bool allowBrokenPipe) {
if (pid == -1) return false;
string str;
@@ -144,7 +144,8 @@ bool Process::writeLine(const string_view line) {
ssize_t nw = write(infd, str.data() + cursor, str.size() - cursor);
if (nw < 0) {
if (errno == EINTR) continue;
- // perror("write");
+ if (allowBrokenPipe && errno == EPIPE) continue;
+ perror("write");
return false;
}
cursor += nw;