SPRING 2024                             December 26, 2023
---------------------------------------------------------------
1.  Introduction

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

 1. Compile all fork source code files + orphan.c + zombie.c

 % 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

Makefile   : Be careful with editing the Makefile
             TABs are important and if you turn a TAB into 
             space or delete it you will regret it.

Some of the fork[1234].c files are described in Subject 3.

fork1.c    : A minimal C code program having a fork 
fork2.c    : A less minimal C code program having a fork 

fork3.c    : A complete C code program using  a fork, 
             inspecting properly the return value of the fork,
             and 
             having the parent process waiting for the child 
             process to complete its execution,
             thus
             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.
             BE CAREFUL WITH return values!
fork5.c    : Eliminated. It has become fork4.c
fork6.c    : Child process runs another program (in fact a script)!
fork7.c    : Array differences for parent and child!
fork8.c    : Try to reason with this program's output
fork9.c    : Use of shmem ; the parent passed to its child its pid;
             child negates pid of parent!


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 (terminal) 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 your NJIT UCID also indicated in the 
             first column of the output.

mysleep.c
spawn.c    : No comment provided


Other additional files are auxiliary. Explore them!

  TWO WAYS to KILL a PROCESS  ; KILL means TERMINATE :-)
NOTE: If in trouble CTRL-C kills process 
      that prevents you from interacting with the bash shell.

      CTRL-C : with the CTRL button depressed you also press 
               the c button

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.
