wait(null) and wait(&status) C language and Status
48,990
Solution 1
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.
Solution 2
wait(NULL)
will only wait until the child process is completed.
But,
wait(&status)
will return the process id of the child process that is terminated.
pid = wait(&status); // the information is returned
Related videos on Youtube
Author by
user3260388
Updated on November 06, 2020Comments
-
user3260388 over 3 years
What is the difference between
wait(null)
andwait(&status)
in c system programming?And what is the content of the pointer status ?
-
Deduplicator about 10 yearsFixed your tags. THis is not really a C question, but a POSIX question.
-