Skip to Main Content
Hands-On System Programming with Linux
book

Hands-On System Programming with Linux

by Kaiwan N. Billimoria, Tigran Aivazian
October 2018
Beginner content levelBeginner
794 pages
19h 23m
English
Packt Publishing
Content preview from Hands-On System Programming with Linux

The wait API – details

In our simpsh program, we did use the wait(2) API, but have not really delved into details:

pid_t wait(int *wstatus);

The thing to understand is this: wait(2) is a blocking call; it causes the calling process to block until a child process dies.

To be technically correct, the wait(2) (and associated APIs that we shall see later) actually block upon the child process(es) undergoing a state change; well, the state change is the child's death, right? Yes, but it's really important to understand that it's not just that: the possible state changes are as follows:

  • The child process terminates as follows:
    • Normally (by falling off main, or calling [_]exit())
    • Abnormally (killed by a signal).
  • The child was sent a signal ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux System Programming Techniques

Linux System Programming Techniques

Jack-Benny Persson
Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini

Publisher Resources

ISBN: 9781788998475Supplemental Content