add timeout when writing in blocking mode on unix
add timeout when writing in blocking mode on unix

Summary:
I don't know if we strictly need this because I saw what looked like a
blocked write when looking at the output of quickstack, but later realized that
quickstack was printing a nonsensical stack trace anyway.

I'm putting it up for review anyway because I don't always trust the kernel
to give timely notifications for dead connections.

If the descriptor is opened in blocking mode, we'll try to write out the
supplied buffer whenever `poll(2)` tells us that writing will not block
and propagate back any errors.  We use a timeout on the `poll` call to
avoid blocking forever.

I've only added this for unix systems at this time.

Reviewed By: sid0

Differential Revision: D4282285

fbshipit-source-id: 3a3ee4beefbcd2322536fe626d170319fcbcc132

nodakai/watchman,nodakai/watchman,facebook/watchman,facebook/watchman,facebook/watchman,nodakai/watchman,wez/watchman,kwlzn/watchman,wez/watchman,kwlzn/watchman,facebook/watchman,kwlzn/watchman,wez/watchman,facebook/watchman,wez/watchman,wez/watchman,wez/watchman,nodakai/watchman,wez/watchman,nodakai/watchman,nodakai/watchman,kwlzn/watchman,nodakai/watchman,nodakai/watchman,facebook/watchman,kwlzn/watchman,facebook/watchman,wez/watchman,kwlzn/watchman,nodakai/watchman,kwlzn/watchman,wez/watchman,facebook/watchman,facebook/watchman