# wait() function...

**URL:** <https://community.unix.com/t/wait-function/274600>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [October 3, 2010, 11:32am UTC](https://community.unix.com/t/wait-function/274600 "2010-10-03T11:32:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joker40](https://community.unix.com/letter_avatar/joker40/32/6_449c533f586939b6e5f246632a46421f.png) [@joker40](https://community.unix.com/u/joker40)\
**Post date:** [October 3, 2010, 11:32am UTC](https://community.unix.com/t/wait-function/274600/1 "2010-10-03T11:32:10Z")

</div>

when wait() is called by process it blocks calling process until child is done. What happens if calling process have multiple children.  
What does wait(NULL) function do. Waits until all children are done?

---

<div class="post-metadata">

**Author:** ![jim\_mcnamara](https://community.unix.com/letter_avatar/jim_mcnamara/32/6_449c533f586939b6e5f246632a46421f.png) [@jim\_mcnamara](https://community.unix.com/u/jim_mcnamara)\
**Post date:** [October 3, 2010, 12:02pm UTC](https://community.unix.com/t/wait-function/274600/2 "2010-10-03T12:02:16Z")

</div>

No. To wait for all children:

```nohighlight
If the calling process has SA_NOCLDWAIT set or has SIGCHLD
set to SIG_IGN, and the process has no unwaited children
that were transformed into zombie processes, it will block
until all of its children terminate, and wait() will fail
and set errno to ECHILD.

```

Having a NULL argument segfaults. Never tried it personally.
