Anat A.

asked • 10/09/22

OS concept- fork() wait() and execv() system calls


if (!fork())

{if (!fork())
{char* const arguments[] = {"cp", "./img.jpg", "/tmp/", NULL};
execv("/bin/cp", arguments);}exit(0);

}
else {wait(NULL);
}
  1. Explain why the main process is not blocked while the cp process is running
  2. Explain why no zombie is left over by this program

Hello, I'm a little confused about this question. I know that in the first fork, the parent process goes to the else and waits for his child to terminate. Then the second fork creates a grandchild, where the child replaces its image with the grandchild, then exits. But what is happening to the grandchild? How come the parent is not blocked (we have the system called wait(Null) ) and how come there is no zombie if the grandchild is still there? Unless the parent waits for both child and grandchild to terminate?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.