December 2022
-------------
1.  Introduction

This ReadmeS3.txt file describes briefly the code in this directory.
More info on how to compile is available in ReadmeS1.txt related
to j1srcXYZ.tar


 1. Compile all the fork1.c - fork8.c files massively


To compile  the fork files massively execute

 % make clean; make all


or if you know what you are doing,


 % make all



 2. Compile the zombie and orphan file separately



To compile the orphan and zombie files execute

 % make clean; make other

or if you know what you are doing,

 % make other


 3. Description of some of the source files included

This is also indicated in the first three line of the file
known as Makefile. All lines there starting with a #
are comment lines. Be careful with editing the Makefile
TABs are important and if you turn a TAB into space or delete
it you will regret it.


fork1.c    : A minimal C code program having a fork (lousy)
fork2.c    : A less minimal C code program having a fork (still lousy)
fork3.c    : A complete C code program having a fork, inspecting
             properly the return value of the fork and having the
             parent process waiting for the child process to complete
             its execution and capturing the return value of the child
             process properly.
fork4.c    : A variation of fork3.c where all the fork related code
             is isolated in a function other than main.
fork5.c    : Eliminated. It has become fork4.c
fork6.c    : If you want to print stat's value that's the way to do it!
fork7.c    : Further example
fork8.c    : Try to reason with this program's output


orphan.c   : Creating an orphan process. It will take one minute or so
             to complete. The child is going to print twice a line
             containing fval,PID (of the child), PPID (of the child).
             Observe the PPID (of the child) in the two output lines.
zombie.c   : Creating a zombie process temporarily
             A zombie process is indicated in linux with the
             state known as defunct. To appreciate this
             open two sessions. In the first you run the zombie executable
             (rename it also to  myzombie if you want) and in the
             second session run continuously  
                % ps -ef | egrep yourUCID
             where yourUCID is you NJIT UCID also indicated in the first
             column of the output.

mysleep8.c
spawn.c    : No comment provided

Other additional files are auxiliary. Explore them!

NOTE: If in trouble CTRL-C 
      (with the CTRL depressed you also press the c key)
      kills process (eg bash shell's execution) that prevents you
      from interacting with the bash shell.

NOTE: % ps -ef | egrep yourUCID 
      shows in the second column a process's PID. If it is for a
      process 5678 a
      % kill -9 5678
      would kill that process.
 
