Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is wait(NULL) well defined?

Tags:

c

posix

I've read man 3p wait, but what I could only find was this statement:

In this case, if the value of the argument stat_loc is not a null pointer, information shall be stored in the location pointed to by stat_loc.

I could also find opengroup page on google, but it was almost exactly same with man 3p wait.
Where can I find explicit statement that says wait(NULL) is well defined?

like image 292
kjh6b6a68 Avatar asked Aug 07 '26 09:08

kjh6b6a68


1 Answers

I don't think you'll find an explicit statement, but this is typical wording for this situation. If they meant that NULL was not allowed, you would see a statement like "stat_loc shall be a non-NULL pointer" or "stat_loc shall point to an object..." or "if stat_loc is NULL, the behavior is undefined".

In this case, it just means that if you pass a null pointer, the defined behavior is that wait just ignores it, and doesn't store that information anywhere at all.

like image 165
Nate Eldredge Avatar answered Aug 09 '26 01:08

Nate Eldredge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!