• Description:
    Like the previous exercise, your program creates a process tree from the argv[1] and argv[2]. The purpose of argv[] is just like exercise 2. Each process when created will print a line to show its label, pid, and ppid. However the order is not specified. In another shell or window, you can send signal to the leaves. When a leaf terminated by a signal, its parent, waiting for children, will know the terminated signal and will print a line. When all children are waited, the internal node process will exit with a value equal to number of nodes in the subtree rooted with that process.
  • Deadline: 2010 Apr 8 00:05am
  • Put your file(s) under ~/usp-982/exer3
  • Examples :
                      shell
                        | 
                        a
                       / \
                      b   e
                     / \   \
                    c   d   f
    $ ./a.out ddduduudduuu abcdef
    I'm c, my pid=9693, and my ppid=9692
    I'm d, my pid=9695, and my ppid=9692
    I'm f, my pid=9696, and my ppid=9694
    I'm e, my pid=9694, and my ppid=9691
    I'm b, my pid=9692, and my ppid=9691
    I'm a, my pid=9691, and my ppid=9572
    child 9693 signaled with signal 1            $ kill -1 9693  # node c
    child 9696 signaled with signal 2            $ kill -2 9696  # node f
    child 9694 exited with value 2                               # node e exited
    child 9695 signaled with signal 3            $ kill -3 9695  # node d
    child 9692 exited with value 3                               # node b exited
    $ echo $?                                                    # node a exited
    6                                                            
    $