You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You must follow the same [principles](https://public.01-edu.org/subjects/0-shell/) as the first subject.
6
-
7
-
Job control refers to the ability to selectively stop (suspend) the execution of processes and continue (resume) their execution at a later point.
8
-
9
-
In `job control`, you will have to implement the following [builtins](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Job-Control-Builtins):
10
-
11
-
- jobs
12
-
- bg
13
-
- fg
14
-
- kill
15
-
16
-
You must also be able to stop jobs with the `Ctrl + Z`.
4
+
In this project, you'll extend the `0-shell` project by adding `job control`. Job control refers to the ability to selectively stop (suspend) the execution of processes and continue (resume) their execution at a later point. With job control, your shell will let users run processes both in the foreground and background.
17
5
18
6
### Instructions
19
-
20
-
- The project has to be written in a compiled language like (C, Rust Go or other), **interpreted languages like (Perl and others) are not allowed**.
21
-
- The code must respect the [good practices](https://public.01-edu.org/subjects/good-practices/)
22
-
23
-
This project will help you learn about:
24
-
25
-
- Job control
26
-
- Process creation and synchronization
27
-
- Commands syntax
28
-
- Scripting language
7
+
- The project has to be written in a Rust.
8
+
- The project must follow the same [principles](https://public.01-edu.org/subjects/0-shell/) as the first subject.
9
+
- The code must respect the [good practices](https://public.01-edu.org/subjects/good-practices/).
10
+
- You must implement the following commands:
11
+
- The `&` operator to run processes in the background.
12
+
- `jobs` (supporting `-r`, `-l`, `-p`, `-s`)
13
+
- `bg`
14
+
- `fg`
15
+
- `kill` (including handling for job specifiers like `%1`)
###### Was the project written in a compiled programming language?
3
+
###### Was the project written in Rust?
4
4
5
5
#### Functional
6
6
7
-
##### Try to run the command `"tar -czf home.tar.gz . &"` then run the command `"jobs"`.
7
+
##### Try to run the command `ls -lRr / 2>1 >/dev/null &` then run the command `jobs`.
8
8
9
9
```
10
-
[1]+ Running tar -czf home.tar.gz . &
10
+
[1]+ Running ls -lRr / 2>1 >/dev/null &
11
11
```
12
12
13
13
###### Can you confirm that the program displayed a list with the status of all jobs like in the example above?
14
14
15
-
##### Try to run the command `"jobs -l"`.
15
+
##### Try to run the command `jobs -l`.
16
16
17
17
```
18
-
[1]+ 13612 Running tar -czf home.tar.gz . &
18
+
[1]+ 13612 Running ls -lRr / 2>1 >/dev/null &
19
19
```
20
20
21
-
###### Can you confirm that the program added the process ID to the normal information given in the command `"jobs"` like in the example above?
21
+
###### Can you confirm that the program added the process ID to the normal information given in the command `jobs` like in the example above?
22
22
23
-
##### Try to run the command `"jobs -p"`.
23
+
##### Try to run the command `jobs -p`.
24
24
25
25
```
26
26
13612
27
27
```
28
28
29
29
###### Can you confirm that the program only displays the process ID like in the example above?
30
30
31
-
##### Try to run the command `"sleep 50000 &"` then run `"python &"` and press enter without any input in the last command.
31
+
##### Try to run the command `sleep 50000 &` then run `cat &` and press enter without any input in the last command.
32
32
33
33
```
34
-
[1] Running tar -czf home.tar.gz . &
34
+
[1] Running ls -lRr / 2>1 >/dev/null &
35
35
[2]- Running sleep 50000 &
36
-
[3]+ Stopped python
36
+
[3]+ Stopped cat
37
37
```
38
38
39
-
###### Run the command `"jobs"`. Can you confirm that the program displays the list with the status of all jobs and that one of them is "Stopped" like the example above?
39
+
###### Run the command `jobs`. Can you confirm that the program displays the list with the status of all jobs and that one of them is "Stopped" like the example above?
40
40
41
-
##### Try to run the command `"jobs -r"`.
41
+
##### Try to run the command `jobs -r`.
42
42
43
43
```
44
-
[1] Running tar -czf home.tar.gz . &
44
+
[1] Running ls -lRr / 2>1 >/dev/null &
45
45
[2]- Running sleep 50000 &
46
46
```
47
47
48
48
###### Can you confirm that the program only displays the list with running jobs like in the example above?
49
49
50
-
##### Try to run the command `"jobs -s"`.
50
+
##### Try to run the command `jobs -s`.
51
51
52
52
```
53
-
[3]+ Stopped python
53
+
[3]+ Stopped cat
54
54
```
55
55
56
56
###### Can you confirm that the program only displays the list with stopped jobs like in the example above?
57
57
58
-
##### Try to run the command `"kill 7764"`(the process ID must be yours this is just an example).
58
+
##### Try to run the command `kill 7764`(the process ID must be yours this is just an example).
59
59
60
60
```
61
61
[2]- Terminated sleep 50000
62
62
```
63
63
64
64
###### Can you confirm that the program killed and displayed the process with the given id like in the example above?
65
65
66
-
##### Try to run the command `"kill %1"`.
66
+
##### Try to run the command `kill %1`.
67
67
68
68
```
69
-
[1] Terminated tar -czf home.tar.gz
69
+
[1] Terminated ls -lRr / 2>1 >/dev/null
70
70
```
71
71
72
72
###### Can you confirm that the program killed and displayed the first process like in the example above?
73
73
74
-
##### Close the program and run it again. Try to run the commands `"tar -czf home.tar.gz . &"`, `"sleep 50000 &"` and then run `"fg"`.
74
+
##### Close the program and run it again. Try to run the commands `ls -lRr / 2>1 >/dev/null &`, `sleep 50000 &` and then run `fg`.
75
75
76
76
```
77
77
sleep 50000
@@ -80,20 +80,20 @@ sleep 50000
80
80
81
81
###### Can you confirm that the program brings the background job to the foreground like in the example above?
82
82
83
-
##### Try to run the command `"fg"` then stop the process with the `"Ctrl + Z"`.
83
+
##### Try to run the command `fg` then stop the process with the `Ctrl + Z`.
84
84
85
85
```
86
86
sleep 50000
87
87
^Z
88
88
[2]+ Stopped sleep 50000
89
89
```
90
90
91
-
###### Can you confirm that the program brings the background job to the foreground and after you press `"Ctrl + Z"` the process stops like in the example above?
91
+
###### Can you confirm that the program brings the background job to the foreground and after you press `Ctrl + Z` the process stops like in the example above?
92
92
93
-
##### Try to run the command `"bg"`.
93
+
##### Try to run the command `bg`.
94
94
95
95
```
96
96
[2]+ sleep 50000 &
97
97
```
98
98
99
-
###### Run `"jobs"`. Can you confirm that the program started the process in the background like in the example above?
99
+
###### Run `jobs`. Can you confirm that the program started the process in the background like in the example above?
0 commit comments