CNT5605 - 2016 Summer
Submission due on Blackboard by midnight on Friday, August 5th.

Assignment: Replace PID 1


Write a C or assembly language program to replace the /sbin/init program for this qemu image of a LFS installation (the root password is 'password'):

  1. Your new /sbin/init should, of course, replace normal PID 1 functionality of starting programs
  2. It should also reap any child process terminations via waitpid(2)
  3. Add process monitoring and restarting capability for selected child programs

Assignment Details

Many people have argued that PID 1 should only do a minimal amount of work, and leave the bulk of system initialization to a child process of PID 1; perhaps the most compelling argument is made by Rich Felker here. (A counterpoint to this argument can be found here.)

The assignment here is to write a slightly extended version of the current Felker init.

First, your new, extended init program should start, in sequence, all of the programs in a new file to be called "/etc/init-transient", but not monitor those. It should then, in daemontools fashion, start and monitor some very important processes. These will be found in a new file named "/etc/init-persistent". If any of these stop, then your program should re-start them.

The syntax for a "start-up" line is the same for both files:


The idea is that the element "PROGRAM" is the absolute path name to the program to be executed; "ARG0" is the first argument (conventionally, this has been an identifier that you like to see in the process table for this process. Clearly this syntax is not comprehensive since execve(2) also allows one to specify environmental variables.)

Here are the entries for your /etc/init-persistent file:


Also, your /etc/init-transient file should have entries for all of the /etc/rc.d/rcS.d/ scripts, and it should finally have an entry for starting the script /etc/init.d/network.

Submission: Make a tar file that includes your /etc/init-persistent, /etc/init-transient, and your new init.c program, and submit it on Blackboard by midnight Friday, August 5.