I have the following code, which creates the defined number of child threads using `fork()`:

```
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>

#define NUM_THREADS     4

int main()
{
        int i;
        pid_t pid;
        for(i = 0; i < NUM_THREADS; i++){ //Do this equal to the number of threads
            pid = fork();//Use this to avoid multiple forking

            if(pid == 0){ //If it's a child process
                    printf("Hello World! Greetings from PID: %ld! :D\n", (long)getpid()); //getpid returns the pid of the process
                    exit(0); //Exit the process
            }else if(pid == -1){
                    printf("Oh no! Could not fork! :( Exiting!\n");
                    return 0;
            }
    }
    int status;
    for(i = 0; i < NUM_THREADS; i++){
            wait(&status);//wait until all the children processes have finished.
    }
    printf("All done! I am the parent process! My PID is: %ld if you were curious! \n", (long)getpid());

    return 0;

```

}

This was provided to us as an example. 
Its output is like:

> 
> Hello World! Greetings from PID: 118358! :D  
> 
>  Hello World! Greetings from PID: 118359! :D  
> 
>  Hello World! Greetings from PID: 118360! :D  
> 
>  Hello World! Greetings from PID: 118362! :D
> 
> 
> 

What I'd like to do, instead of having 1 parent process with many children, is to have the parent create a child process, which creates a child process, and so on for the defined number of threads. How can I do that?