diff options
Diffstat (limited to 'pc')
-rw-r--r-- | pc/ChangeLog | 5 | ||||
-rw-r--r-- | pc/gawkmisc.pc | 38 |
2 files changed, 25 insertions, 18 deletions
diff --git a/pc/ChangeLog b/pc/ChangeLog index c0027c38..d1acbf50 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,8 @@ +2021-12-01 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.pc (os_maybe_set_errno): Renamed from + w32_maybe_set_errno. Add check for errno values. + 2021-11-21 Arnold D. Robbins <arnold@skeeve.com> * Makefile.tst: Regenerated. 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__ */ |