Question: 1. Write a simple program to print the PID (process ID) and PPID (parent process ID) of the underlying process. Repeat the execution multiple

1. Write a simple program to print the PID (process ID) and PPID (parent process ID) of the underlying process. Repeat the execution multiple times (from the shell), then answer the following questions: (a) Is the PID the same in all runs? Why/why not? (b) Is the PPID the same in all runs? Why/why not? Hint: use the getpid and getppid systems calls to get the PID and PPID of a process respectively. 2. Modify the program in part 1 so that the main process creates a child process, and each of the two processes prints its PID and PPID. The parent process must wait until the child process terminates. (a) Verify the parent-child relationship between the two processes. 3. Write a program that continuously asks the user to enter a command (with no arguments). When the user enters a command, the program forks a child process to execute it (using execlp) while it waits until the child finishes execution. The program quits when the user enters "exit" as a command. 4. Write a program to draw the following process tree. Verify the correctness of your solution using the PIDs and PPIDs of the generated processes. P P3 P Main process P4 Ps P6
Step by Step Solution
There are 3 Steps involved in it
1a Certainly Heres a simple Python program that prints the PID process ID and PPID parent process ID of the underlying process import os Get the PID and PPID pid osgetpid ppid osgetppid Print the PID ... View full answer
Get step-by-step solutions from verified subject matter experts
