errno 10 ought to be ECHILD. The manpage for wait says
ERRORS ECHILD (for wait) The calling process does not have any unwaited-for children.
ECHILD (for waitpid) The process specified in pid does not exist or is not a child of the calling process. (This can happen for one's own child if the action for SIGCHLD is set to SIG_IGN. See also the LINUX NOTES section about threads.)
Not all that helpful, perhaps...