Index: sys/amd64/linux/linux_machdep.c =================================================================== --- sys/amd64/linux/linux_machdep.c +++ sys/amd64/linux/linux_machdep.c @@ -503,11 +503,12 @@ args->pid, (void *)args->status, args->options, (void *)args->rusage); #endif + if (args->options & ~(LINUX_WUNTRACED | LINUX_WNOHANG | + LINUX_WCONTINUED | __WCLONE | __WNOTHREAD | __WALL)) + return (EINVAL); - options = (args->options & (WNOHANG | WUNTRACED)); - /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ - if (args->options & __WCLONE) - options |= WLINUXCLONE; + options = WEXITED; + linux_to_bsd_waitopts(args->options, &options); if (args->rusage != NULL) rup = &ru; Index: sys/amd64/linux32/linux32_machdep.c =================================================================== --- sys/amd64/linux32/linux32_machdep.c +++ sys/amd64/linux32/linux32_machdep.c @@ -1031,8 +1031,11 @@ args->pid, (void *)args->status, args->options, (void *)args->rusage); #endif + if (args->options & ~(LINUX_WUNTRACED | LINUX_WNOHANG | + LINUX_WCONTINUED | __WCLONE | __WNOTHREAD | __WALL)) + return (EINVAL); - options = (WNOHANG | WUNTRACED); + options = WEXITED; linux_to_bsd_waitopts(args->options, &options); if (args->rusage != NULL) Index: sys/compat/linux/linux_misc.c =================================================================== --- sys/compat/linux/linux_misc.c +++ sys/compat/linux/linux_misc.c @@ -891,16 +891,13 @@ printf(ARGS(waitpid, "%d, %p, %d"), args->pid, (void *)args->status, args->options); #endif - options = (WNOHANG | WUNTRACED); - linux_to_bsd_waitopts(args->options, &options); - - /* - * this is necessary because the test in kern_wait doesn't work - * because we mess with the options here - */ - if (options & ~(WUNTRACED | WNOHANG | WCONTINUED | WLINUXCLONE)) + if (args->options & ~(LINUX_WUNTRACED | LINUX_WNOHANG | + LINUX_WCONTINUED | __WCLONE | __WNOTHREAD | __WALL)) return (EINVAL); + options = WEXITED; + linux_to_bsd_waitopts(args->options, &options); + return (linux_common_wait(td, args->pid, args->status, options, NULL)); } #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ Index: sys/i386/linux/linux_machdep.c =================================================================== --- sys/i386/linux/linux_machdep.c +++ sys/i386/linux/linux_machdep.c @@ -1051,8 +1051,11 @@ args->pid, (void *)args->status, args->options, (void *)args->rusage); #endif + if (args->options & ~(LINUX_WUNTRACED | LINUX_WNOHANG | + LINUX_WCONTINUED | __WCLONE | __WNOTHREAD | __WALL)) + return (EINVAL); - options = (WNOHANG | WUNTRACED); + options = WEXITED; linux_to_bsd_waitopts(args->options, &options); if (args->rusage != NULL)