Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: wait4(2) do not fail with WNOHANG if there is no child



On Sun, Nov 06, 2016 at 09:34:17AM +0100, Nicolas Joly wrote:
> 
> Hi,
> 
> Just encountered a case where wait(4) + WNOHANG do not fail with
> expected ECHILD when there is no process to wait.
> 
> The attached testcase illustrate this :
> 
>   pid = wait4(-1, NULL, 0, NULL);
>   assert(pid == -1 && errno == ECHILD);
>   pid = wait4(-1, NULL, WNOHANG, NULL);
>   assert(pid == -1 && errno == ECHILD);
> 
> The first wait(4) call fails as expected, but the second one makes the
> assert fire because pid == 0 ... where i would have expected same
> failure as previous (-1 + ECHILD)
> 
> njoly@raya [netbsd/funcs]> make wait4
> cc -g -Wall -Werror   -o wait4 wait4.c
> njoly@raya [netbsd/funcs]> ./wait4
> assertion "pid == -1 && errno == ECHILD" failed: file "wait4.c", line
> 13, function "main"

Just tested it on 7.0.2 NetBSD/amd64 under qemu, and it works as
expected. Looks like a -current regression.

-- 
Nicolas Joly

Cluster & Computing Group
Biology IT Center
Institut Pasteur, Paris.


Home | Main Index | Thread Index | Old Index