commit 2db08997c59e73eefd34056fa2c69172e8bed581
parent 91acffc08629c036885d1b471f947103746d78d3
Author: Ed van Bruggen <edvb@uw.edu>
Date: Sat, 21 Dec 2019 23:40:59 -0800
Close file if opened in write
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tibs/io.c b/tibs/io.c
@@ -53,7 +53,10 @@ prim_write(Tsp st, Hash env, Val args)
fprintf(f, "%s", car(v)->v.s);
else
tisp_print(f, car(v));
- fflush(f);
+ if (f == stdout || f == stderr)
+ fflush(f);
+ else
+ fclose(f);
return st->none;
}