diff --git a/include/uv-private/ngx-queue.h b/include/uv-private/ngx-queue.h index 4bd66fc1..3c3ed1b0 100644 --- a/include/uv-private/ngx-queue.h +++ b/include/uv-private/ngx-queue.h @@ -122,7 +122,7 @@ struct ngx_queue_s { #define ngx_queue_foreach(q, h) \ for ((q) = ngx_queue_head(h); \ - (q) != ngx_queue_sentinel(h); \ + (q) != ngx_queue_sentinel(h) && !ngx_queue_empty(h); \ (q) = ngx_queue_next(q)) diff --git a/src/unix/linux/linux-core.c b/src/unix/linux/linux-core.c index 5b3b1164..e92869e3 100644 --- a/src/unix/linux/linux-core.c +++ b/src/unix/linux/linux-core.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -186,6 +187,10 @@ uv_err_t uv_set_process_title(const char* title) { if (process_title.len) strncpy(process_title.str, title, process_title.len - 1); +#if defined(PR_SET_NAME) + prctl(PR_SET_NAME, title); +#endif + return uv_ok_; } diff --git a/src/unix/process.c b/src/unix/process.c index 7c552a73..25b4d5d8 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -321,6 +321,9 @@ static void uv__process_child_init(uv_process_options_t options, dup2(use_fd, i); close(use_fd); } + + if (fd <= 2) + uv__nonblock(fd, 0); } if (options.cwd && chdir(options.cwd)) { diff --git a/src/win/core.c b/src/win/core.c index dde1348a..509ea563 100644 --- a/src/win/core.c +++ b/src/win/core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "uv.h" @@ -40,10 +41,23 @@ static uv_once_t uv_init_guard_ = UV_ONCE_INIT; static uv_once_t uv_default_loop_init_guard_ = UV_ONCE_INIT; +static void uv__crt_invalid_parameter_handler(const wchar_t* expression, + const wchar_t* function, const wchar_t * file, unsigned int line, + uintptr_t reserved) { + /* No-op. */ +} + + static void uv_init(void) { /* Tell Windows that we will handle critical errors. */ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | - SEM_NOOPENFILEERRORBOX); + SEM_NOOPENFILEERRORBOX); + + /* Tell the CRT to not exit the application when an invalid parameter is */ + /* passed. The main issue is that invalid FDs will trigger this behavior. */ +#ifdef _WRITE_ABORT_MSG + _set_invalid_parameter_handler(uv__crt_invalid_parameter_handler); +#endif /* Fetch winapi function pointers. This must be done first because other */ /* intialization code might need these function pointers to be loaded. */ diff --git a/src/win/fs.c b/src/win/fs.c index 4a2d9362..9b920c81 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -1137,9 +1137,12 @@ static void fs__utime(uv_fs_t* req) { if (fs__utime_handle(handle, req->atime, req->mtime) != 0) { SET_REQ_WIN32_ERROR(req, GetLastError()); + CloseHandle(handle); return; } + CloseHandle(handle); + req->result = 0; } diff --git a/src/win/tty.c b/src/win/tty.c index c0676751..adb66a62 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -1186,6 +1186,7 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) { } else if (arg == 49) { /* Default background color */ bg_color = 0; + bg_bright = 0; } else if (arg >= 90 && arg <= 97) { /* Set bold foreground color */