wait(null) and wait(&status) C language and Status

user3260388 picture user3260388 · Apr 15, 2014 · Viewed 44k times · Source

What is the difference between wait(null) and wait(&status) in c system programming?

And what is the content of the pointer status ?

Answer

user43968 picture user43968 · Apr 15, 2014

If you call wait(NULL) (wait(2)), you only wait for any child to terminate. With wait(&status) you wait for a child to terminate but you want to know some information about it's termination.

You can know if the child terminate normally with WIFEXITED(status) for example.

status contains information about processes that you can check with some already defined MACRO.