Skip to content

Commit eca7147

Browse files
committed
finish shell lab
1 parent 6f181db commit eca7147

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+214
-173
lines changed

text_code/ecf/alarm

30.5 KB
Binary file not shown.

text_code/ecf/alarm.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
/* $begin alarm */
22
#include "csapp.h"
33

4-
void handler(int sig)
4+
void handler(int sig)
55
{
66
static int beeps = 0;
77

88
printf("BEEP\n");
9-
if (++beeps < 5)
10-
Alarm(1); /* Next SIGALRM will be delivered in 1 second */
11-
else {
12-
printf("BOOM!\n");
13-
exit(0);
9+
if (++beeps < 5)
10+
Alarm(1); /* Next SIGALRM will be delivered in 1 second */
11+
else
12+
{
13+
printf("BOOM!\n");
14+
exit(0);
1415
}
1516
}
1617

17-
int main()
18+
int main()
1819
{
1920
Signal(SIGALRM, handler); /* Install SIGALRM handler */
20-
Alarm(1); /* Next SIGALRM will be delivered in 1s */
21+
Alarm(1); /* Next SIGALRM will be delivered in 1s */
2122

22-
while (1) {
23-
; /* Signal handler returns control here each time */
23+
while (1)
24+
{
25+
; /* Signal handler returns control here each time */
2426
}
2527
exit(0);
2628
}

text_code/ecf/blockone

30.4 KB
Binary file not shown.

text_code/ecf/counterprob

30.6 KB
Binary file not shown.

text_code/ecf/fork

30.5 KB
Binary file not shown.

text_code/ecf/fork1

30.5 KB
Binary file not shown.

text_code/ecf/fork2

30.5 KB
Binary file not shown.

text_code/ecf/fork3

30.5 KB
Binary file not shown.

text_code/ecf/forkprob0

30.5 KB
Binary file not shown.

text_code/ecf/forkprob0.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include "csapp.h"
22

33
/* $begin forkprob0 */
4-
int main()
4+
int main()
55
{
66
int x = 1;
77

88
if (Fork() == 0)
9-
printf("p1: x=%d\n", ++x); //line:ecf:forkprob0:childfork
10-
printf("p2: x=%d\n", --x); //line:ecf:forkprob0:parentfork
9+
printf("p1: x=%d\n", ++x); //line:ecf:forkprob0:childfork
10+
printf("p2: x=%d\n", --x); //line:ecf:forkprob0:parentfork
1111
exit(0);
1212
}
1313
/* $end forkprob0 */
14-

0 commit comments

Comments
 (0)