diff options
Diffstat (limited to 'tests/ouch.c')
-rw-r--r-- | tests/ouch.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ouch.c b/tests/ouch.c new file mode 100644 index 0000000..c2925c6 --- /dev/null +++ b/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); +} |