Have a look at the output of pstree -ap to see how PIDs and relations are normaslly displayed. Check if the value returned by the fork () method is greater than 0 using the if conditional statement. This is, because for each fork () there will be an exit () to match and for each exit () there must be a wait () somewhere. Tree depth is set by a variable passed as first argument at invocation. The new process is referred to as the child process. "The program should take one command line arguments: number of hierarchy level. According to Linux manual page the definition of fork is-. Operations for creating and interacting with sub-processes. I am trying create a 4-level binary process tree using fork (). As you already know FORK gives two values. The calling process is referred to as the parent process. On Windows it failed for two reasons: - The PATH separator is ';', not ':' on Windows. The main (m in diagram) will create child C1 and both will continue execution. C code to spawn a binary tree of processes using fork(). I want to create a process tree from user input and display this tree with using ‘pstree’. GitHub - williballenthin/process-forest: Reconstruct process trees … Create a Child Process Using the System Calls Fork How to create a child process using Fork system call? - DoAfCo It does not help if you use a non standard way to make a graph. An async-signal-safe function is … The second fork will be itself forked one time. You need to understand that your child will copy (~)all states of their parent. fork, exec, wait and exit | Percona Community Section CS:APP3e-8.4.2 mentions this idea in passing.