Question: EXCERSICES 1. Use the template below to write a C-program that creates two processes: Process A (the process with which the program starts execution) and

EXCERSICES 1. Use the template below to write a C-program that creates two processes: "Process A" (the process with which the program starts execution) and "Process B" (A's child). The Process A forks Process B. To identify which process writes the output, each process puts its id at the beginning of each line (see the sample output). Each process performs the following operations Process A: After spawning Process B, it waits for Process B to terminate. After Process B's termination, it will write your home directory (use HOME environment variable) and its process ID, and terminates. Process B: After being spawned from Process A, it sleeps for three seconds (using sleep) Then, it writes process IDs of itself and Process A immediately. After that, executes ps command (using system library) and terminates. Sample output: ./a.out 9181:1 am the parent, I will create child process 9182:1 am the child, I will sleep for 3 seconds 9182:My parent pid is 9181 9182:the ps command PID TTY TIME CMD 8931 pts/0 00:00:00 bash 9181 pts/0 00:00:00 a.out 9182 pts/0 00:00:00 a.out 9183 pts/0 00:00:00 ps 9181: My home directory is /home/user Template: 78 Page #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
