Question: You can use getpid ( ) to get the process id that is currently running. Like this: int pid = getpid ( ) ; Remember

You can use getpid() to get the process id that is currently running. Like this:
int pid = getpid();
Remember that the original fork call returns the child process id, for the parent to
use!!!!
Obviously, the process id numbers will be different because each computer has its
own process id numbers!!!!
The challenge here is to use the wait(NULL); properly.
Create a program that prints the following, in the same exact order:
I am the parent and my process id is: 2337
My child was created with child process id: 2338
I am the parent, now waiting for my child process to end...
I am the child process! and my process id is: 2338
Child process has ended!!!
I am the parent, my child has ended!
parent process has ended!!!
 You can use getpid() to get the process id that is

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!