If the option argument is invalid, -1 should be returned and errno should be set to EINVAL and this should be done before waiting.
Reproduction (ia32-generic-qemu):
#include <stdio.h>
#include <errno.h>
#include <sys/wait.h>
int main(void)
{
int ret;
int dummy = 123;
ret = waitpid((pid_t)dummy, NULL, dummy);
printf("waitpid ret: %d errno: %d\n", ret, errno);
return 0;
}
