[hackers] [sbase] tee: -i option ignores SIGINT || Greg Reagle
commit 4f0a813ca1407986691f63d7a93dbcd0a55e61af
Author: Greg Reagle <greg.reagle_AT_umbc.edu>
Date: Thu Jan 22 16:08:25 2015 -0500
tee: -i option ignores SIGINT
diff --git a/tee.1 b/tee.1
index 36a1570..297a292 100644
--- a/tee.1
+++ b/tee.1
_AT_@ -3,7 +3,7 @@
tee \- duplicate stdin
.SH SYNOPSIS
.B tee
-.RB [ \-a ]
+.RB [ \-ai ]
.RI [ file ...]
.SH DESCRIPTION
.B tee
_AT_@ -12,3 +12,6 @@ writes from stdin to stdout, making copies in each file.
.TP
.B \-a
append to each file rather than overwriting.
+.TP
+.B \-i
+ignore SIGINT, i.e. the interrupt from keyboard signal
diff --git a/tee.c b/tee.c
index 97307e1..0b4ad8b 100644
--- a/tee.c
+++ b/tee.c
_AT_@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
_AT_@ -8,13 +9,13 @@
static void
usage(void)
{
- eprintf("usage: %s [-a] [file...]\n", argv0);
+ eprintf("usage: %s [-ai] [file...]\n", argv0);
}
int
main(int argc, char *argv[])
{
- int aflag = 0;
+ int aflag = 0, iflag = 0;
char buf[BUFSIZ];
int i, nfps;
size_t n;
_AT_@ -24,10 +25,15 @@ main(int argc, char *argv[])
case 'a':
aflag = 1;
break;
+ case 'i':
+ iflag = 1;
+ break;
default:
usage();
} ARGEND;
+ if (iflag && signal(SIGINT, SIG_IGN) == SIG_ERR)
+ eprintf("signal:");
nfps = argc + 1;
fps = ecalloc(nfps, sizeof *fps);
Received on Tue Mar 24 2015 - 23:53:14 CET
This archive was generated by hypermail 2.3.0
: Wed Mar 25 2015 - 00:02:08 CET