aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-12-27 21:20:47 +0200
committerArnold D. Robbins <arnold@skeeve.com>2014-12-27 21:20:47 +0200
commit15a1d8d213380bd99b5dfe7f4cafcd6dedb8f0dc (patch)
treeddefa874075651711ede984369749a80e4615903 /io.c
parent5909f454e470d5a1de2aea2451e69455bfb398ad (diff)
downloadegawk-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.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/io.c b/io.c
index b4688c89..b3819c01 100644
--- a/io.c
+++ b/io.c
@@ -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