Discuss your understanding using an example:
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
int main() {
pid_t processId = fork();
// parent process fork() > 0
if (processId > 0) {
wait(NULL);
printf("\nParent Process is being Terminated");
}
// child process fork() == 0
else if (processId == 0) {
sleep(3);
wait(NULL);
printf("\nChild Process is being Terminated");
}
return 0;
}
clang version 7.0.0-3~ubuntu0.18.04.1 (tags/RELEASE_700/final)
Child Process is being Terminated
Parent Process is being Terminated
Discuss your understanding using an example: How to create a child process using fork, running a...