Introduction
Using the figure handed out in class,
write a small program
(C/C++) that
has a parent and child process.
The parent process forks the child, then
calls a function which prints out the parent
and child process id (with a tag indicating which
pid is which).
The parent then waits for the child to complete.
Once forked, the child calls a function which
sleeps for a period of seconds where the sleep time
in seconds
is (command line) input as a startup parameter to the program
(data sharing between parent and child).
Once the child wakes up, it prints out the date
(do not use system to do the date, but find
the underlying OS system call)
and terminates.
The printout should delineate between parent and child.
If you have problems with I/O, then make sure to flush.
Script files end up with a lot of control characters. There are at least 2 ways to remove them. One is to try the command col; the other is to cat the file to the screen and then cut and paste.
Last modified Sept 25, 01 by mike@cs.hmc.edu