diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-11-07 20:56:57 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-11-07 20:56:57 +0200 |
commit | ed5e0e468ca758d963b5370ec83f56725087d4f4 (patch) | |
tree | 6ff753ddf047e6a23c7fe15c88ae689bdaaa6fc9 /pc | |
parent | 04601220d136004d188b392945a475cedcaacb03 (diff) | |
parent | e886bf34a4e42095824a2b14c40cb19efa80390f (diff) | |
download | egawk-ed5e0e468ca758d963b5370ec83f56725087d4f4.tar.gz egawk-ed5e0e468ca758d963b5370ec83f56725087d4f4.tar.bz2 egawk-ed5e0e468ca758d963b5370ec83f56725087d4f4.zip |
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'pc')
-rw-r--r-- | pc/ChangeLog | 5 | ||||
-rw-r--r-- | pc/gawkmisc.pc | 26 |
2 files changed, 28 insertions, 3 deletions
diff --git a/pc/ChangeLog b/pc/ChangeLog index 2b4b1183..49ce73fa 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,8 @@ +2016-11-04 Eli Zaretskii <eliz@gnu.org> + + * gawkmisc.pc (w32_maybe_set_errno) [__MINGW32__]: New function, + to correct errno when it is not set to a useful value. + 2016-10-23 Arnold D. Robbins <arnold@skeeve.com> * General: Remove trailing whitespace from all relevant files. diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc index 9939fb48..817e8167 100644 --- a/pc/gawkmisc.pc +++ b/pc/gawkmisc.pc @@ -1,6 +1,4 @@ -/* - * gawkmisc.c --- miscellaneous gawk routines that are OS specific. - */ +/* gawkmisc.c --- miscellaneous gawk routines that are OS specific. -*-C-*- */ /* * Copyright (C) 1986, 1988, 1989, 1991 - 2003, 2012, 2016 @@ -897,6 +895,28 @@ w32_status_to_termsig (unsigned status) return SIGTERM; } +void +w32_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; + } +} + #endif /* __MINGW32__ */ #if defined(__DJGPP__) || defined(__MINGW32__) || defined(__EMX__) |