From: <ch...@su...> - 2013-06-27 14:26:47
|
Hi! > > This version looks nearly fine. I would check the return value from > > waitpid() too, just for the sake of completness. > > > So, something like this is ok: > if (waitpid(pid, &ret, 0) != pid) > tst_brkm(..."waitpid failed at ...") Yes. > > And looking at the waitpid() documentation it states that it uses only > > two bytes from ret (in reality it's cleared to zero but that is not > > promised in specification). > > > > I would change the last condition to: > > > > if (!WIFEXITED(ret) || WEXITSTATUS(ret) != 0) { > > > > } > But the waitpid() manual says that WEXITSTATUS should only be employed > if WIFEXITED returned true, so may be change it to: > if (!WIFEXITED(ret) || (WIFEXITED(ret) && WEXITSTATUS(ret) != 0)) { > ... > } The short circuit evaluation will take care of that. -- Cyril Hrubis ch...@su... |