Hi, Martin,
ret = select(pipefd + 1, &readfds, &writefds, &errorfds, NULL);
Passing NULL instead of &writefds in this case is better, IMO. It is not used anyway. ...and... I strongly believe that errorfds parameter os select() is useful for sockets only, not for stdio (I am not sure whether it is true for Darwin). Please, check this.
-- Kirill