diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-12-27 21:20:47 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-12-27 21:20:47 +0200 |
commit | 15a1d8d213380bd99b5dfe7f4cafcd6dedb8f0dc (patch) | |
tree | ddefa874075651711ede984369749a80e4615903 /io.c | |
parent | 5909f454e470d5a1de2aea2451e69455bfb398ad (diff) | |
download | egawk-15a1d8d213380bd99b5dfe7f4cafcd6dedb8f0dc.tar.gz egawk-15a1d8d213380bd99b5dfe7f4cafcd6dedb8f0dc.tar.bz2 egawk-15a1d8d213380bd99b5dfe7f4cafcd6dedb8f0dc.zip |
Make nonfatal work with stdout & stderr. Update doc more.
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -1085,6 +1085,25 @@ getredirect(const char *str, int len) return NULL; } +/* is_non_fatal_std --- return true if fp is stdout/stderr and nonfatal */ + +bool +is_non_fatal_std(FILE *fp) +{ + if (in_PROCINFO("nonfatal", NULL, NULL)) + return true; + + /* yucky logic. sigh. */ + if (fp == stdout) { + return ( in_PROCINFO("-", "nonfatal", NULL) != NULL + || in_PROCINFO("/dev/stdout", "nonfatal", NULL) != NULL); + } else if (fp == stderr) { + return (in_PROCINFO("/dev/stderr", "nonfatal", NULL) != NULL); + } + + return false; +} + /* close_one --- temporarily close an open file to re-use the fd */ static void |