diff options
Diffstat (limited to 'usrbin')
| -rw-r--r-- | usrbin/main.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/usrbin/main.c b/usrbin/main.c index 31d38c1..d1e3adc 100644 --- a/usrbin/main.c +++ b/usrbin/main.c @@ -1,17 +1,31 @@ +#include <errno.h> #include <signal.h> #include <stdint.h> #include <stdio.h> #include <time.h> #include <unistd.h> +void sighandler(int sig) { + printf("Signal received!\n"); +} + void pid1(void) { ssize_t in; char buf[2] = { 0, 0 }; printf("We did it ma!\n"); + signal(1, &sighandler); while(1) { in = read(buf, 1); + if(in <= 0) { + if(in == -EINTR) { + printf("Read call interrupted!\n"); + kill(getpid(), SIGKILL); + } else { + pause(); + } + } if(in > 0) puts(buf); } @@ -24,6 +38,8 @@ void pid2(void) { while(1) { sleep(1); + if(time() == 2) + kill(1, 1); printf("0x%04x:0x%08x: 0x%08x, 0x%08x\n", getpid(), (uint32_t) getpdir(), time(), x++); } } |
