-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
60 lines (49 loc) · 1.57 KB
/
Copy pathtest.sh
File metadata and controls
60 lines (49 loc) · 1.57 KB
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
N=10
BLUE='\e[34m'
YELLOW='\e[33m'
BLACK='\e[30m'
printf "$YELLOW"
echo "compiling with N=$N"
gcc -DN=$N echo-server.c -o echo-server-foreground
printf "starting server $BLACK\n"
setsid ./echo-server-foreground &
sleep 3
echo "this text is printed by echo-server and got from 'echo' command!" > /tmp/echo_fifo
cat test.txt > /tmp/echo_fifo
pkill -USR1 echo-server-for
sleep 1
printf "$YELLOW"
printf "waiting $N seconds for alarm to ring$BLACK\n"
sleep $N
printf "$YELLOW"
printf "done sleeping, now sending another message $BLACK\n"
echo "another message after sleeping" > /tmp/echo_fifo
printf "$YELLOW"
printf "now going to demonize the echo-server and do all over again $BLACK\n"
pkill -HUP echo-server-for
sleep 1
printf "$YELLOW"
printf "sending messages to server $BLACK\n"
echo "this text is printed by echo-server and got from 'echo' command!" > /tmp/echo_fifo
cat test.txt > /tmp/echo_fifo
pkill -USR1 echo-server-for
sleep 1
printf "$YELLOW"
printf "waiting $N seconds for alarm to ring$BLACK\n"
sleep $N
printf "$YELLOW"
printf "done sleeping, now sending another message $BLACK\n"
echo "another message after sleeping" > /tmp/echo_fifo
printf "$YELLOW"
printf "the end of test $BLACK\n"
pkill -TERM echo-server-for
sleep 1
printf "$YELLOW"
printf "now running server in console with side program\n"
printf "every line written in console is sent to echo_fifo\n"
printf "all lines are treated as one big message. Quiting client will also turn off the server$BLACK\n"
setsid ./echo-server-foreground &
sleep 3
pkill echo-server-for -2
gcc echo-client.c -o echo-client
./echo-client