Question: Copy and paste this program into a C file on compsci. Compile it and run it 3 or 4 times. What will the following program
Copy and paste this program into a C file on compsci. Compile it and run it 3 or 4 times. What will the following program print? Explain the output that was produced or make your best guess as to why you got this output.
#include#include #include int main(void) { pid_t child_pid; printf("The main program process ID is %d ", (int)getpid()); child_pid = fork(); if (child_pid != 0) { printf("This is the parent process, with id %d ", (int) getpid()); printf("The child\'s process ID is %d ", (int) child_pid); } else printf("This is the child process, with id %d ", (int)getpid()); return(0); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
