diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-12-01 22:46:18 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-12-01 22:46:18 +0200 |
commit | 0521e672efdbfdaedabfacca03c7a535b4f8526c (patch) | |
tree | 96c5db398195d2b81d66a891fae0848b97bfe87d /pc/gawkmisc.pc | |
parent | a22095c81a677b82accccb53cab91052cdc0cbfe (diff) | |
parent | f77e1318c515d495ac9c08bdfdf2dadf79a9649f (diff) | |
download | egawk-0521e672efdbfdaedabfacca03c7a535b4f8526c.tar.gz egawk-0521e672efdbfdaedabfacca03c7a535b4f8526c.tar.bz2 egawk-0521e672efdbfdaedabfacca03c7a535b4f8526c.zip |
Merge branch 'gawk-5.1-stable'
Diffstat (limited to 'pc/gawkmisc.pc')
-rw-r--r-- | pc/gawkmisc.pc | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc index 1843a168..149ea62c 100644 --- a/pc/gawkmisc.pc +++ b/pc/gawkmisc.pc @@ -1066,25 +1066,27 @@ w32_status_to_termsig (unsigned status) } void -w32_maybe_set_errno (void) +os_maybe_set_errno (void) { - DWORD w32err = GetLastError (); - - switch (w32err) - { - /* When stdout is redirected to a pipe, and the program that - reads the pipe (e.g., a pager) exits, Windows doesn't set - errno to a useful value. Help it DTRT. */ - case ERROR_BAD_PIPE: - case ERROR_PIPE_BUSY: - case ERROR_NO_DATA: - case ERROR_PIPE_NOT_CONNECTED: - errno = EPIPE; - break; - default: - errno = EINVAL; - break; - } + if (errno == 0 || errno == EINVAL) { + DWORD w32err = GetLastError (); + + switch (w32err) + { + /* When stdout is redirected to a pipe, and the program that + reads the pipe (e.g., a pager) exits, Windows doesn't set + errno to a useful value. Help it DTRT. */ + case ERROR_BAD_PIPE: + case ERROR_PIPE_BUSY: + case ERROR_NO_DATA: + case ERROR_PIPE_NOT_CONNECTED: + errno = EPIPE; + break; + default: + errno = EINVAL; + break; + } + } } #endif /* __MINGW32__ */ |