0
- 24123 rt_sig ?
00:00:00 java
040 S
0
171
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
040 S
0
172
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
140 S
0
173
169
0
69
0
- 24123 nanosl ?
00:01:23 java
040 S
0
174
169
0
69
0
- 24123 nanosl ?
00:00:00 java
040 S
0
175
169
0
69
0
- 24123 nanosl ?
00:00:00 java
040 S
0
176
169
0
69
0
- 24123 nanosl ?
00:00:00 java
100 S
99
179
131
0
69
0
-
2465 do_pol ?
00:01:51 squid
040 S
0
180
169
0
69
0
- 24123 nanosl ?
00:00:00 java
000 S
99
181
179
0
69
0
-
300 pipe_w ?
00:00:00 unlinkd
040 S
0
183
169
0
69
0
- 24123 nanosl ?
00:00:00 java
040 S
0
184
169
0
69
0
- 24123 nanosl ?
00:00:00 java
140 S
0
185
169
0
69
0
- 24123 wait_f ?
00:00:00 java
040 S
0
191
169
0
69
0
- 24123 wait_f ?
00:00:00 java
040 S
0
192
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
040 S
0
193
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
040 S
0
194
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
040 S
0
195
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
040 S
0
196
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
040 S
0
197
169
0
69
0
- 24123 wait_f ?
00:00:00 java
140 S
99
708
121
0
69
0
-
862 wait_f ?
00:00:02 httpd
140 S
99
709
121
0
69
0
-
857 wait_f ?
00:00:02 httpd
140 S
99 32559
121
0
69
0
-
857 wait_f ?
00:00:02 httpd

140 S
99 12395
121
0
69
0
-
859 wait_f ?
00:00:02 httpd
140 S
99 17529
121
0
69
0
-
860 wait_f ?
00:00:02 httpd
140 S
0 23388
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
140 S
0 23389
169
0
69
0
- 24123 rt_sig ?
00:00:00 java
140 S
0 31584
77
0
69
0
-
1488 unix_s ?
00:00:00 sshd
140 S
1002 31586 31584
0
70
0
-
1336 do_sel ?
00:00:00 sshd
000 S
1002 31587 31586
0
72
0
-
502 wait4
pts/0
00:00:00 bash
000 R
1002 31612 31587
0
77
0
-
795 -
pts/0
00:00:00 ps
hong:~ $
As you can see most processes are run by the root and are not
associated w with any terminal (
TTY=?
). Some of these are daemons, or
servers.
Another option
-H
displays the process hierarchy, ie parent-child
relationship. For example:
[email protected]:~$ ps -efH | grep S900432D
S900432D 32628 32625
0 21:19 ?
00:00:00
sshd:
[email protected]/0
S900432D 32629 32628
0 21:19 pts/0
00:00:00
-bash
S900432D
958 32629
0 22:20 pts/0
00:00:00
ps
-efH
S900432D
959 32629
0 22:20 pts/0
00:00:00
grep S900432D
[email protected]:~$
The above command line consists of two commands
ps -efH
and
grep
S900432D
connected by a pipe ("|"), which links the standard output of
the first command with the standard input of the second command. The
command
grep
picks up those input lines that contains the string
"S900432D". The output in the above command line shows all
processes started by the user "S900432D". It also reveals hierarchical
structures of these processes.
Try all commands used in this questions and try to understand the
output with the help of manual page of the
ps
command.
7.
Killing Processes
You can kill any process you own by sending the signal SIGKILL
(signal 9). Firstly you need to find out the PID of the process you want
to kill, then use the command

kill -9
pid
Note you cannot kill a process that is owned by other users. However
root can kill any process.
Theory Exercises
Stallings (5th edition): Problems 3.1, 3.2, and 3.4 (page 150). or
Stallings (6th edition): Problems 3.1, 3.4, and 3.6 (page 154).
C Programming Exercises
Note, all exercises must be done via the terminal commands, not GUI
tools. Do not use IDE to build your programs. Do not use GUI file
managers to manage your directories and files. Also, each exercise
should be in a separate directory, which itself, is under a directory
called
lab04
1.
Arrays and Pointers
In C, arrays and pointers can be used interchangeably in most
situations. Let's look at the following example:
int ai[10];
int *pi;
int i;
for (i=0; i<10; ++i)
ai[i] = i + 100;
// initialise each array element
pi = ai;
// let pi point to the array
// alternatively, pi = &ai[0];
