linux: handle EPOLLHUP without EPOLLIN/EPOLLOUT

Work around an epoll quirk where it sometimes reports just the EPOLLERR
or EPOLLHUP event.  In order to force the event loop to move forward,
we merge in the read/write events that the watcher is interested in;
uv__read() and uv__write() will then deal with the error or hangup in
the usual fashion.

Fixes #982.

This is a back-port of commit 24bfef2 from the master branch.
unix: fix reopened fd bug

When fd is closed and new one (with the same number) is opened inside
kqueue/epoll/port loop's callback - stale events might invoke callbacks
on wrong watchers.

Check if watcher was changed after invocation and invalidate all events
with the same fd.

fix #826
core: fix fake watcher list and count preservation

Fake watcher list and count should be preserved only if
`loop->watchers` was already allocated.
Merge branch 'v0.10'

Conflicts:
	build.mk
	src/unix/core.c
	src/unix/darwin.c
2013.11.13, Version 0.10.19 (Stable)

Changes since version 0.10.18:

* darwin: avoid calling GetCurrentProcess (Fedor Indutny)

* unix: update events from pevents between polls (Fedor Indutny)

* fsevents: support japaneese characters in path (Chris Bank)

* linux: don't turn on SO_REUSEPORT socket option (Ben Noordhuis)

* build: fix windows smp build with gyp (Geert Jansen)

* linux: handle EPOLLHUP without EPOLLIN/EPOLLOUT (Ben Noordhuis)

* unix: fix reopened fd bug (Fedor Indutny)

* core: fix fake watcher list and count preservation (Fedor Indutny)
Now working on v0.10.20
unix: unbreak bsd build after bbccafb

Unbreak the build on the BSDs after commit bbccafb.  Move the new
uv__platform_invalidate_fd() function from src/unix/darwin.c to
src/unix/kqueue.c.
Merge remote-tracking branch 'origin/v0.10'

Conflicts:
	AUTHORS
	ChangeLog
	src/unix/darwin.c
	src/version.c
build: add test-tcp-close-accept.c to test deps

Add test/test-tcp-close-accept.c to the dependency list of the
`make check` target of the autotools build.
test: test fsevents error reporting

Create a lot of `FSEventStream`s to make `FSEventStreamStart()` fail.
Fetch the error code and verify that it is correct.
unix: set close-on-exec flag on received fds

Set the close-on-exec flag on file descriptors that we've received with
recvmsg() so we don't leak them when calling fork() afterwards.

On Linux, we use the MSG_CMSG_CLOEXEC flag when supported (2.6.23 and
up.)

On older Linux versions and other platforms, we walk the received file
descriptors and set the close-on-exec flag for each fd manually.  That
won't entirely avoid race conditions when other threads call fork() or
clone() but at least we're less likely to leak file descriptors now.
test: don't connect to 0.0.0.0

OpenBSD won't let you do that, the connect() system call fails with
an EINVAL error.  Connect to 127.0.0.1 instead.
netbsd, openbsd: enable futimes() wrapper

OpenBSD and NetBSD have working futimes() implementations.  This commit
makes uv_fs_futime() work on those platforms.
unix: nicer error message when kqueue() fails

Print the error message rather than just the errno.  The fact that the
errno is 24 is only informative to people that have their operating
system's error codes memorized.
samples: add socks5 proxy sample application
2013.11.21, Version 0.11.15 (Unstable)

Changes since version 0.11.14:

* fsevents: report errors to user (Fedor Indutny)

* include: UV_FS_EVENT_RECURSIVE is a flag (Fedor Indutny)

* linux: use CLOCK_MONOTONIC_COARSE if available (Ben Noordhuis)

* build: make systemtap probes work with gyp build (Ben Noordhuis)

* unix: update events from pevents between polls (Fedor Indutny)

* fsevents: support japaneese characters in path (Chris Bank)

* linux: don't turn on SO_REUSEPORT socket option (Ben Noordhuis)

* queue: strengthen type checks (Ben Noordhuis)

* include: remove uv_strlcat() and uv_strlcpy() (Ben Noordhuis)

* build: fix windows smp build with gyp (Geert Jansen)

* unix: return exec errors from uv_spawn, not async (Alex Crichton)

* fsevents: use native character encoding file paths (Ben Noordhuis)

* linux: handle EPOLLHUP without EPOLLIN/EPOLLOUT (Ben Noordhuis)

* windows: use _snwprintf(), not swprintf() (Ben Noordhuis)

* fsevents: use FlagNoDefer for FSEventStreamCreate (Fedor Indutny)

* unix: fix reopened fd bug (Fedor Indutny)

* core: fix fake watcher list and count preservation (Fedor Indutny)

* unix: set close-on-exec flag on received fds (Ben Noordhuis)

* netbsd, openbsd: enable futimes() wrapper (Ben Noordhuis)

* unix: nicer error message when kqueue() fails (Ben Noordhuis)

* samples: add socks5 proxy sample application (Ben Noordhuis)
Now working on v0.11.16
fsevents: remove kFSEventStreamCreateFlagNoDefer polyfill

The kFSEventStreamCreateFlagNoDefer flag is already
defined in CarbonCore/FSEvents.h since OS X 10.5.

Fixes #1000.
libuv: add more getaddrinfo errors
unix: fix accept() EMFILE error handling

Fix a bug that was introduced in commit 3ee4d3f ("unix, windows:
return error codes directly") and add a regression test for good
measure.

Hat tip to Fedor for pointing out the issue.

Fixes #1007.