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

  • Home
  • SEARCH
  • 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 8773721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:22:30+00:00 2026-06-13T18:22:30+00:00

I was reading about the wait() function in a Unix systems book. The book

  • 0

I was reading about the wait() function in a Unix systems book. The book contains a program which has wait(NULL) in it. I don’t understand what that means. In other program there was

while(wait(NULL)>0) 

…which also made me scratch my head.

Can anybody explain what the function above is doing?

  • 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-13T18:22:31+00:00Added an answer on June 13, 2026 at 6:22 pm

    man wait(2)

    All of these system calls are used to wait for state changes in
    a child of the calling process, and obtain information about the child
    whose state has changed. A state change is considered to be: the child terminated; the child was stopped by a signal; or the child was resumed by a signal

    So wait() allows a process to wait until one of its child processes change its state, exists for example. If waitpid() is called with a process id it waits for that specific child process to change its state, if a pid is not specified, then it’s equivalent to calling wait() and it waits for any child process to change its state.

    The wait() function returns child pid on success, so when it’s is called in a loop like this:

    while(wait(NULL)>0) 
    

    It means wait until all child processes exit (or change state) and no more child processes are unwaited-for (or until an error occurs)

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

Sidebar

Related Questions

When reading about pipes in Advanced Programming in the UNIX Environment, I noticed that
I am reading about what an interface contains and I understand in addition to
Reading about Delphi's Exit statement (see here for instance), I cannot ignore that writing
i was reading Zend Framework Book: Survive the Deep End about resource methods. it
I am new to UNIX programming and i was reading about zombie processes and
Thanks for reading. I've noticed that if I have a page that has one
After reading about semaphores I tried this test code in which I create two
I was reading about CreateProcess function in c++ and I wanted to try it.
Reading about the Dispose pattern , I see the documentation repeatedly refer to cleaning
Reading about Kohana templates and saw something I've never seen before: $this->template->title = __('Welcome

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.