aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
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