CS476/576
Assignment #3
Due Midnight,
Wednsday Oct 27, 2004
Write a C/UNIX program with the following descriptions:
NAME
pchain -
A program that creates a chain of processes.
SYNOPSIS
pchain n
DESCRIPTION
- <>The
program creates n
processes, process i creates
process i+1, for i=1,
2, ...n-1.>
- <>The first process creates
a unique temporary file T with name /tmp/pchainXXXXXX. >
- <>Each process writes its
own pid in T. >
- <>The last process displays
the content of T and then exits. >
- <>When a prcess
detects the death of its child, it displays the content T and then
exits. >
- <>The first process deletes
T before it exits.>
- <>All
process should access file T through its shared fd.>
Program output
Upon
the creation of process
i, the program displays the
message:
Process i is
created: PID=<pid1>, ParentPID=<pid2>, ChildPID=<pid3>
where <pid1>,
<pid2> and <pid3> are processes ids.
Upon the termination of process i, the program
displays following:
Process i is
terminated and the list of process is:
.....list
all processes......