Back to UNIX page

Process tree

Write an application that creates a process tree of height h with height being defined as distance from node to any leaf. Each non-leaf node should have n children. The root node sends SIGUSR1 and SIGUSR2 signals interchangeably, every one second, to its children (only children, not all descendants). Nodes forward any delivered signals to their children respectively. Should a leaf node receive a SIGUSR1 signal and in case its PID is odd, it has 50% chance of dying. Same rule applies to leaf nodes regarding SIGUSR2 and even PIDs. Each process should track the number of its children. Any process with all its children dead should end its life as well. All non-leaf processes display their current number of children before or after each iteration. C-c does not prevent the application from running.

0 < n < 6, 0 < h < 6 are command line parameters.

Hint: in certain situations you might want to ignore ESRCH error.

Solutions will be graded by Jurek Bartuszek. Copy your tarballs to /home2/samba/bartuszekj/unix/ .

We pay extra attention to:

Back to UNIX page