[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
awk: ignore SIGPIPE
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: awk: ignore SIGPIPE
- From: Matthias Kilian <kili_(_at_)_outback_(_dot_)_escape_(_dot_)_de>
- Date: Wed, 29 Mar 2006 15:11:37 +0200
- Mail-followup-to: tech_(_at_)_openbsd_(_dot_)_org
Hi,
IMHO, awk(1) should ignore SIGPIPE. Currently, if awk(1) get's a
SIGPIPE when writing to a pipe, it just dies. With the patch below,
it dies, too, but at least you get a reasonable error message.
diff -x CVS -rNu ../awk.orig/main.c ./main.c
--- ../awk.orig/main.c Thu Dec 30 14:06:17 2004
+++ ./main.c Wed Mar 29 15:05:20 2006
@@ -69,6 +69,7 @@
exit(1);
}
signal(SIGFPE, fpecatch);
+ signal(SIGPIPE, SIG_IGN);
yyin = NULL;
symtab = makesymtab(NSYMTAB);
while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') {
Sample awk script:
#!/usr/bin/awk -f
BEGIN {
for (i = 0; i < 32768; i++)
print "" | "./foo"
x = close("./foo")
print x
}
Matching "foo":
#!/bin/sh
echo foo
Any Comments?
Ciao,
Kili
ps: I've some more diffs to awk(1) around, but I first have to sort
out what's usable and what is junk or still incomplete.
Visit your host, monkey.org