summaryrefslogtreecommitdiff
path: root/libc/tests/ouch.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/tests/ouch.c')
-rw-r--r--libc/tests/ouch.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libc/tests/ouch.c b/libc/tests/ouch.c
new file mode 100644
index 0000000..c2925c6
--- /dev/null
+++ b/libc/tests/ouch.c
@@ -0,0 +1,27 @@
+
+#include <signal.h>
+#include <stdio.h>
+#include <errno.h>
+
+void trap()
+{
+ write(1, "Ouch!!\n", 7);
+}
+
+main()
+{
+ char buf[2];
+ int cc;
+
+ signal(SIGINT, trap);
+ while( (cc=read(0, buf, 1)) > 0 || (cc == -1 && errno == EINTR) )
+ {
+ if( cc < 0 )
+ fprintf(stderr, "INTR\n");
+ else
+ fprintf(stderr, "%x\n", buf[0]);
+ }
+
+
+ write(1, "\nExit!\n", 7);
+}