blob: d1e3adcc0d4385c89cb3fa23fa8794f87c6630db (
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
|
#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);
}
}
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) {
if(getpid() == 1) {
ctty(1);
pid1();
}
pid2();
}
|