diff options
author | Tom Smeding <tom@tomsmeding.com> | 2021-10-16 11:28:38 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2021-10-16 11:28:38 +0200 |
commit | 006f8b49d9ebe1ca334b934d0a127c0029300871 (patch) | |
tree | fe973fdecedb6f43fccbd8ffb70a5a82f51d59f3 /process.cpp | |
parent | c01700906812f949c9088709b6c34307fbf63338 (diff) |
'writemaybe' command to allow broken pipe errors
Diffstat (limited to 'process.cpp')
-rw-r--r-- | process.cpp | 5 |
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; |