I know fork(), wait(), waitpid(), zombie processes... I understood them by reading W. Richard Stevens which is a very good book.
If we don't call wait() in parent the child becomes a zombie after termination... which is bad!
If we call wait() in parent then parent waits for child to terminate, receives the termination status and then continues. Write?
I have gone through many examples that call fork() once and then wait() in parent.
But if at all parent is going to wait for child and continue after the child terminates, then there is no actual multitasking going on(technically yes there are 2 processes. But logically of no use) then why did we call fork() here?
We could have written child's code and then parent's code instead of fork() & wait() as a single process...wouldn't it be better?
Thanks!