unix: fix uv_spawn() NULL pointer deref on ENOMEM

In the cleanup-after-error section of uv_spawn(), check that the pointer
is non-NULL - we might end up in said section due to a malloc() failure.
unix: don't close inherited fds on uv_spawn() fail

The cleanup-after-error code path in uv_spawn() was closing file
descriptors indiscriminately.  Only close file descriptors that we
created ourselves, not the ones that are passed in by the user.

Fixes joyent/node#6297.
unix: revert recent FSEvent changes

This commit reverts the following commits:

    983fa68 darwin: fix 10.6 build error in fsevents.c
    684e212 fsevents: use shared FSEventStream
    ea4cb77 fsevents: FSEvents is most likely not thread-safe
    9bae606 darwin: create fsevents thread on demand

Several people have reported stability issues on OS X 10.8 and bus
errors on the 10.9 developer preview.

See also joyent/node#6296 and joyent/node#6251.
test: relax TTY availability assumptions

test-tty.c currently assumes that a TTY is available to the test runner,
and fails hard if not. This may not be true on some autobuilding
environment, making the build fail as shown in [0].
Instead, let's properly skip the test in such cases.

[0] http://ur1.ca/fr5bd

Signed-off-by: Luca Bruno <lucab@debian.org>
test: relax timing assumption of loop_stop

The loop_stop test makes an implicit assumption about the triggering
timing of a repeating trigger, which may not hold true on slower or
virtualized machines, thus failing the test as shown at [0] and
discussed at [1].
This commit relaxes the assumption, without mandating the exact number
of runs.

[0] http://ur1.ca/fr5bw
[1] https://groups.google.com/d/msg/libuv/5-fNIC7hIAo/yqznDmwHDAIJ

Signed-off-by: Luca Bruno <lucab@debian.org>
test: relax timing assumption of timer_again

timer_again test makes an implicit assumption on the triggering
timing of a repeating timer. However, this assumption may be not
true on slower or virtualized architecture due to delay accumulation,
which may fail the test as show in [0].
This commit makes explicit checks conforming to the asserted behavior.

[0] http://ur1.ca/fr5c4

Signed-off-by: Luca Bruno <lucab@debian.org>
linux: ignore fractional time in uv_uptime()

Before this commit, uv_uptime() returned the nanoseconds as the
fractional part of the uptime.  It's a bit inconsistent with the
output on other platforms because those only return whole seconds
(with the possible exception of Windows.)

This commit changes linux-core.c to only return whole seconds.
unix: fix SIGCHLD waitpid() race in process.c

Before this commit, multiple event loops raced with each other when a
SIGCHLD signal was received.  More concretely, it was possible for
event loop A to consume waitpid() events that should have been
delivered to event loop B.

This commit addresses that by doing a linear scan over the list of
child processes.  An O(n) scan is not terribly efficient but the
actual performance impact is not measurable in a benchmark that spawns
rounds of several thousands instances of /bin/false.  For the time
being, this patch will suffice; we can always revisit it later.

Fixes #887.
.gitignore: fix .deps/, add .dirstamp
unix, windows: add uv_fs_event_start/stop functions

Make uv_fs_event behave like other handles, that is, it's inactive after
init, and it's active between start and stop.
unix: fix non-synchronized access in signal.c

Check the return value of uv__signal_lock(); don't mutate the signal
watcher tree in the signal handler if we failed to acquire the lock.
Merge remote-tracking branch 'origin/v0.10'

Conflicts:
	include/uv-darwin.h
	src/unix/fsevents.c
	src/unix/process.c
fsevents: poll when FSEvents fail

As Apple documentation for FSEvents suggests, we should fall-back to
polling directory for changes when `FSEventStreamStart()` fails and
returns `false`.

The fall-back has one drawback though - it doesn't work for
subdirectories.