mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
don't warn about EPIPE errors
Emitting warnings about EPIPE errors when writing to stdout or stderr is more annoying than helpful. So suppress that specific warning message. Fixes #2516
This commit is contained in:
parent
430d82bd4f
commit
6f8775499f
2 changed files with 15 additions and 5 deletions
|
@ -511,6 +511,8 @@ long read_blocked(int fd, void *buf, size_t count) {
|
|||
return res;
|
||||
}
|
||||
|
||||
/// Loop a write request while failure is non-critical. Return -1 and set errno in case of critical
|
||||
/// error.
|
||||
ssize_t write_loop(int fd, const char *buff, size_t count) {
|
||||
size_t out_cum = 0;
|
||||
while (out_cum < count) {
|
||||
|
|
|
@ -499,15 +499,23 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
|||
/// Perform output from builtins. May be called from a forked child, so don't do anything that may
|
||||
/// allocate memory, etc.
|
||||
bool do_builtin_io(const char *out, size_t outlen, const char *err, size_t errlen) {
|
||||
int saved_errno = 0;
|
||||
bool success = true;
|
||||
if (out && outlen && write_loop(STDOUT_FILENO, out, outlen) < 0) {
|
||||
int e = errno;
|
||||
saved_errno = errno;
|
||||
if (errno != EPIPE) {
|
||||
debug_safe(0, "Error while writing to stdout");
|
||||
errno = saved_errno;
|
||||
safe_perror("write_loop");
|
||||
}
|
||||
success = false;
|
||||
errno = e;
|
||||
}
|
||||
|
||||
if (err && errlen && write_loop(STDERR_FILENO, err, errlen) < 0) success = false;
|
||||
if (err && errlen && write_loop(STDERR_FILENO, err, errlen) < 0) {
|
||||
saved_errno = errno;
|
||||
success = false;
|
||||
}
|
||||
|
||||
errno = saved_errno;
|
||||
return success;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue