This is not really my most familiar bit of the code, so you gdbserver guys check me, ok? It seems to me that we need to set errno to zero before calling waitpid, if we're going to check it right after. Especially the second time.