build: make gyp_uv understand '-f ninja'
unix: fix EMFILE busy loop

Don't spin in epoll_wait() / kevent() / port_getn() / etc. when we can't
accept() a new connection due to having reached the file descriptor limit.
Pass the error to the connection_cb and let the libuv user deal with it.
unix: code cleanup, rename variable
unix: put child process stdio fds in blocking mode

Remove the O_NONBLOCK flag from file descriptors 0-2, most applications don't
expect EAGAIN errors when dealing with stdio.
win/tty: reset background brightness when color is set to default
linux: improve /proc/cpuinfo parser

Make uv_cpu_info() understand the ARM and MIPS versions of /proc/cpuinfo,
it only knew how to deal with the x86 version

This commit also fixes a buglet where uv_cpu_info() reported the maximum CPU
frequency instead of the actual CPU frequency. That is, before this commit
`out/Debug/run-tests platform_output | grep speed | sort | uniq -c` on my
system always reported:

      8   speed: 3400

Now it reports (for example):

      2   speed: 3400
      6   speed: 1600

In other words, two CPUs are running at full speed while the others have been
scaled back because they're mostly idle.

This is a back-port of commit 54bfb66 from the master branch.

Fixes #526.
unix: map EDQUOT to UV_ENOSPC
windows: don't blow up when an invalid FD is used
windows: fix application crashed popup in debug version

This is a backport of 2 patches by Ting-Yu Lin and Hiroaki Nakamura.
windows: fix handle leak in uv_fs_utime
win: fix compilation with MSVCRT < 8.0
linux: update comm field in uv_set_process_title()

Makes the new process name visible in both `ps` and `ps a`, with the caveat
that `ps` will only print the first 16 characters.

Before this commit, `ps` kept reporting the old process name.
Revert "unix: avoid iterating over all async handles"

This reverts commit 209abbab27abdc63200cbd707f72fed4245ab4d0.

Fixes the following SIGSEGV:

  (gdb) f 1
  #1  0x00007fc084683aec in uv__async_io (loop=0x7fc0848e0b40,
  handle=0x7fc0848e0c78, events=1) at src/unix/async.c:175
  175             ASYNC_CB(h)
  (gdb) list
  170
  171         /* If we need to sweep all handles anyway - skip this loop */
  172         if (!loop->async_sweep_needed) {
  173           for (i = 0; i < end; i += sizeof(h)) {
  174             h = *((uv_async_t**) (buf + i));
  175             ASYNC_CB(h)
  176           }
  177         }
  178
  179         bytes -= end;
  (gdb) print *h
  $1 = {close_cb = 0x184e1b0, data = 0x18d9520, loop = 0x7fc0848e0b40,
  type = 49, handle_queue = {prev = 0x18dae10, next = 0x7860c0}, flags = 32,
  next_closing = 0x1863b40, pending = 0, async_cb = 0x31,
  queue = {prev = 0x18dae50, next = 0x7860c0}}
  (gdb)

It looks like the async handle gets closed or otherwise becomes invalid before
the sweep is executed.

Fixes #603.
unix: reopen tty as /dev/tty

Reopen the file descriptor when it refers to a tty. This lets us put the tty in
non-blocking mode without affecting other processes that share it with us.

Fixes #601.
benchmark: timed_udp_pummel should not write to closed udp handle

This fixes intermittent assertion failures when running the benchmark.
benchmark: async_pummel should not call uv_async_send on closed handle

This fixes an assertion that triggered in debug builds on Windows.
include: fix ngx_queue_foreach() macro

Guard against the possibility that the queue is emptied while we're iterating
over it. Simple test case:

  #include "ngx-queue.h"
  #include <assert.h>

  int main(void) {
    ngx_queue_t h;
    ngx_queue_t v[2];
    ngx_queue_t* q;
    unsigned n = 0;
    ngx_queue_init(&h);
    ngx_queue_insert_tail(&h, v + 0);
    ngx_queue_insert_tail(&h, v + 1);
    ngx_queue_foreach(q, &h) {
      ngx_queue_remove(v + 0);
      ngx_queue_remove(v + 1);
      n++;
    }
    assert(n == 1); // *not* 2
    return 0;
  }

Fixes #605.
Merge branch 'v0.8'
unix: fix ‘fd’ undeclared build error

Reapplies commit b5028c5b, failed to merge in 5cb4197.
windows: closing handles should always keep the loop alive

This makes the tcp-ref2 and udp-ref2 tests pass again.
Also adds another reference count test.