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

冷暖自知 提交于 2019-11-29 16:24:14

问题


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

And what is the content of the pointer status ?


回答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.




回答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


来源:https://stackoverflow.com/questions/23092231/waitnull-and-waitstatus-c-language-and-status

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!