ECS518U Operating Systems
ECS518U Operating Systems
Lab 4 Answer Sheet
1
Answer Sheet
This answer sheet should be completed (using a pen is fine).
1.1 Step 1: Behaviour of myRunShell0.php
Answer the following questions about the behaviour of myRunShell0.php.
Question
Answer
What happens when the
myRunShell0.php script is used
to run an external program?
What requirement does this
behaviour not implement?
Why does this behaviour occur?
(Refer to the documentation of
pcntl_exec)
1.2 Step 2: Use of pcntl_fork
Answer the following questions about the use of pcntl_fork:
Question
Answer
What happens when the
pcntl_fork function is executed?
What PHP function is used to
make the parent process wait for
the child process to complete?
Version 1.0, 08/02/2015
Page 1
ECS518U Operating Systems
1.3 Step 3: Use of Cntrl-C
Consider the following scenario: the shell (e.g. myRunShell.php) is used to run the script
zzz.php. The user types Ctrl-C to terminate the zzz.php script. Assume that the processes
running are shown below:
PID
PPID CMD
21881 20774 php myRunShell.php
22075 21881 /usr/bin/php ./zzz.php
Complete the following list (adding extra entries if you wish) describing the sequence of
events that occur when the user type Ctrl-C:
1. The OS delivers the
(pcntl_wexitstatus).
2. The function
signal to process 21881, which is waiting
runs in process 21881 and
3.
4.
5.
6. Process 21881 complete the runCmd function and displays the prompt for the next
command to myRunShell.php
Version 1.0, 08/02/2015
Page 2