Ok, then if waitpid returns -1 (which doesn't necessarily mean "invalid child id"), that means you need to check errno for the error code (I probably should have said so in my previous post).

You could also try calling waitpid with a pid of -1 to make it wait for "any" child process and do the same (check the return value and errno).