logo

utils-std

Collection of commonly available Unix tools
commit: c1e0362f779e8f1a26a6a3e9162e2ed33cdc57a7
parent 800141a1b88475fb8b0d5d89644f8c808540da19
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 16 Mar 2024 21:58:18 +0100

cmd/tee: implement -i

Diffstat:

Mcmd/tee.c7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cmd/tee.c b/cmd/tee.c @@ -5,12 +5,13 @@ #define _POSIX_C_SOURCE 200809L #include <assert.h> /* assert() */ #include <errno.h> /* errno */ +#include <signal.h> /* signal() */ #include <stdio.h> /* fprintf(), fgetc(), fputc(), fclose(), fopen() */ #include <stdlib.h> /* malloc(), free(), abort() */ #include <string.h> /* strerror() */ #include <unistd.h> /* getopt(), opt… */ -void +static void cleanup(FILE **fds) { if(fds != NULL) @@ -34,6 +35,7 @@ main(int argc, char *argv[]) mode = "a"; break; case 'i': /* ignore SIGINT */; + signal(SIGINT, SIG_IGN); break; } } @@ -95,7 +97,8 @@ main(int argc, char *argv[]) { if(fclose(fds[argi]) != 0) { - abort(); + fprintf(stderr, "tee: I/O error when closing file '%s': %s\n", argv[argi], strerror(errno)); + err++; } }