Fixes T4219. See comments. PHP returns 0 when writing to nonblocking pipes for both "everything is OK, but this pipe is blocked, so you should wait a little bit and try again" and "nothing is OK, this pipe is broken forever".
This was causing an busy loop in ssh-exec, where it would check if stderr was writable, see it was, try to write to it, get a 0-length write, interpret that as "wait a bit", wait for it to become writable (i.e., immediately!), try to write again, etc.
This was the best workaround I could come up with. I think it should be pretty safe; I'm not aware of any temporary condition or event which can make a pipe unwritable after a select says it's writable other than a write.