Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8607597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:23:57+00:00 2026-06-12T03:23:57+00:00

I know fork(), wait(), waitpid(), zombie processes… I understood them by reading W. Richard

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:23:58+00:00Added an answer on June 12, 2026 at 3:23 am

    Sometimes, it is useful to fork() even if the parent is immediately going to block. The most common case is when you are doing something akin to the system() call, executing an external command and waiting for it to complete: you will do fork() + execve(). (Though, in modern code, you should consider using posix_spawn() instead for this purpose.)

    Nevertheless, wait() does not need to block. You can use waitpid() with flag WNOHANG to collect exit code of any completed process or continuing immediately if it is still running.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that fork() returns differently for the child and parent processes, but I'm
If I do Process.fork do x end how can I know what x returned
I have homework that should use fork() and wait() system calls: 1) Write two
int main(){ fork(); } I know this is a newbie question, but my understanding
I'm working on an Unix-Shell, using C langage. I use waitpid to wait my
I know this is normally rather stupid, but don't shoot me before reading the
I am trying to create multiple processes using fork() and execvp() calls, but so
I'm trying to fork a sub-process, wait for it to finish, if it doesn't
I'm trying to fork 3 different child processes from a parent (and running this
I know what the fork() does at the higher level. What I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.