blob: 70c0ab3338a2d334d437909a19afcc3ca0a7fdf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#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, };
printf("We did it ma!\n");
signal(1, &sighandler);
while(1) {
in = read(buf, 1);
if(in < 1) {
if(in == -EINTR) {
printf("Read call interrupted!\n");
/* kill(getpid(), SIGKILL); */
} else {
printf("Error reading from serial port!\n");
kill(getpid(), SIGKILL);
}
}
if(in == 0) {
printf("EOF detected!\n");
panic();
}
if(in > 0)
puts(buf);
}
}
void pid2(void) {
int x = 0;
printf("We did it ma!\n");
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++);
}
}
void main(void) {
int i;
char c = 'a';
char buf[2048];
/*
* for(i = 0; i < 2048; i++) {
* buf[i] = c;
*
* c++;
* if(c > 'z')
* c = 'a';
* }
* ctty(1);
* write(buf, 2048);
* while(1);
*/
if(getpid() == 1) {
ctty(1);
pid1();
}
pid2();
}
|