diff options
-rw-r--r-- | deps/uv/AUTHORS | 1 | ||||
-rw-r--r-- | deps/uv/ChangeLog | 65 | ||||
-rw-r--r-- | deps/uv/build.mk | 10 | ||||
-rw-r--r-- | deps/uv/config-unix.mk | 15 | ||||
-rw-r--r-- | deps/uv/src/unix/darwin-proctitle.c | 12 | ||||
-rw-r--r-- | deps/uv/src/unix/pipe.c | 39 | ||||
-rw-r--r-- | deps/uv/src/unix/stream.c | 48 | ||||
-rw-r--r-- | deps/uv/src/unix/tcp.c | 96 | ||||
-rw-r--r-- | deps/uv/src/unix/udp.c | 96 | ||||
-rw-r--r-- | deps/uv/src/version.c | 6 | ||||
-rw-r--r-- | deps/uv/src/win/process.c | 39 | ||||
-rw-r--r-- | deps/uv/test/test-process-title.c | 6 | ||||
-rw-r--r-- | deps/uv/test/test-tty.c | 8 | ||||
-rw-r--r-- | deps/uv/uv.gyp | 9 |
14 files changed, 233 insertions, 217 deletions
diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 1562f4a68..90b3235bb 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -85,3 +85,4 @@ Kristian Evensen <kristian.evensen@gmail.com> Nils Maier <maierman@web.de> Nicholas Vavilov <vvnicholas@gmail.com> Miroslav Bajtoš <miro.bajtos@gmail.com> +Elliot Saba <staticfloat@gmail.com> diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index c96f8086e..9b29dc2cd 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,4 +1,67 @@ -2013.05.11, Version 0.11.2 (Unstable) +2013.05.16, Version 0.11.3 (Unstable) + +Changes since version 0.11.2: + +* unix: clean up uv_accept() (Ben Noordhuis) + +* unix: remove errno preserving code (Ben Noordhuis) + +* darwin: fix ios build, don't require ApplicationServices (Ben Noordhuis) + +* windows: kill child processes when the parent dies (Bert Belder) + +* build: set soname in shared library (Ben Noordhuis) + +* build: make `make test` link against .a again (Ben Noordhuis) + +* build: only set soname on shared object builds (Timothy J. Fontaine) + +* build: convert predefined $PLATFORM to lower case (Elliot Saba) + +* test: fix process_title failing on linux (Miroslav Bajtoš) + +* test, sunos: disable process_title test (Miroslav Bajtoš) + +* test: add error logging to tty unit test (Miroslav Bajtoš) + + +2013.05.15, Version 0.10.7 (Stable), 028baaf0846b686a81e992cb2f2f5a9b8e841fcf + +Changes since version 0.10.6: + +* windows: kill child processes when the parent dies (Bert Belder) + + +2013.05.15, Version 0.10.6 (Stable), 11e6613e6260d95c8cf11bf89a2759c24649319a + +Changes since version 0.10.5: + +* stream: fix osx select hack (Fedor Indutny) + +* stream: fix small nit in select hack, add test (Fedor Indutny) + +* build: link with libkvm on openbsd (Ben Noordhuis) + +* stream: use harder sync restrictions for osx-hack (Fedor Indutny) + +* unix: fix EMFILE error handling (Ben Noordhuis) + +* darwin: fix unnecessary include headers (Daisuke Murase) + +* darwin: rename darwin-getproctitle.m (Ben Noordhuis) + +* build: convert predefined $PLATFORM to lower case (Elliot Saba) + +* build: set soname in shared library (Ben Noordhuis) + +* build: make `make test` link against .a again (Ben Noordhuis) + +* darwin: fix ios build, don't require ApplicationServices (Ben Noordhuis) + +* build: only set soname on shared object builds (Timothy J. Fontaine) + + +2013.05.11, Version 0.11.2 (Unstable), 3fba0bf65f091b91a9760530c05c6339c658d88b Changes since version 0.11.1: diff --git a/deps/uv/build.mk b/deps/uv/build.mk index d3a9046b9..abdd1396f 100644 --- a/deps/uv/build.mk +++ b/deps/uv/build.mk @@ -18,7 +18,11 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') +ifdef PLATFORM +override PLATFORM := $(shell echo $(PLATFORM) | tr "[A-Z]" "[a-z]") +else +PLATFORM = $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') +endif CPPFLAGS += -I$(SRCDIR)/include -I$(SRCDIR)/include/uv-private @@ -140,10 +144,10 @@ TESTS= \ all: libuv.a -run-tests$(E): test/run-tests.o test/runner.o $(RUNNER_SRC) $(TESTS) libuv.$(SOEXT) +run-tests$(E): test/run-tests.o test/runner.o $(RUNNER_SRC) $(TESTS) libuv.a $(CC) $(CPPFLAGS) $(RUNNER_CFLAGS) -o $@ $^ $(RUNNER_LIBS) $(RUNNER_LDFLAGS) -run-benchmarks$(E): test/run-benchmarks.o test/runner.o $(RUNNER_SRC) $(BENCHMARKS) libuv.$(SOEXT) +run-benchmarks$(E): test/run-benchmarks.o test/runner.o $(RUNNER_SRC) $(BENCHMARKS) libuv.a $(CC) $(CPPFLAGS) $(RUNNER_CFLAGS) -o $@ $^ $(RUNNER_LIBS) $(RUNNER_LDFLAGS) test/echo.o: test/echo.c test/echo.h diff --git a/deps/uv/config-unix.mk b/deps/uv/config-unix.mk index 3cecb57bd..67aaa140a 100644 --- a/deps/uv/config-unix.mk +++ b/deps/uv/config-unix.mk @@ -29,7 +29,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64 RUNNER_SRC=test/runner-unix.c RUNNER_CFLAGS=$(CFLAGS) -I$(SRCDIR)/test -RUNNER_LDFLAGS=-L"$(CURDIR)" -luv -Xlinker -rpath -Xlinker "$(CURDIR)" +RUNNER_LDFLAGS=-L"$(CURDIR)" -luv HAVE_DTRACE= DTRACE_OBJS= @@ -64,7 +64,6 @@ HAVE_DTRACE=1 CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 LDFLAGS+=-lkstat -lnsl -lsendfile -lsocket # Library dependencies are not transitive. -RUNNER_LDFLAGS += $(LDFLAGS) OBJS += src/unix/sunos.o OBJS += src/unix/dtrace.o DTRACE_OBJS += src/unix/core.o @@ -87,8 +86,7 @@ endif CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 LDFLAGS += -framework Foundation \ -framework CoreServices \ - -framework ApplicationServices \ - -dynamiclib -install_name "@rpath/libuv.dylib" + -framework ApplicationServices SOEXT = dylib OBJS += src/unix/darwin.o OBJS += src/unix/kqueue.o @@ -144,12 +142,19 @@ CPPFLAGS += -Isrc/unix CFLAGS += -DHAVE_DTRACE endif +ifneq (darwin,$(PLATFORM)) +# Must correspond with UV_VERSION_MAJOR and UV_VERSION_MINOR in src/version.c +SO_LDFLAGS = -Wl,-soname,libuv.so.0.11 +endif + +RUNNER_LDFLAGS += $(LDFLAGS) + libuv.a: $(OBJS) $(AR) rcs $@ $^ libuv.$(SOEXT): override CFLAGS += -fPIC libuv.$(SOEXT): $(OBJS:%.o=%.pic.o) - $(CC) -shared -o $@ $^ $(LDFLAGS) + $(CC) -shared -o $@ $^ $(LDFLAGS) $(SO_LDFLAGS) include/uv-private/uv-unix.h: \ include/uv-private/uv-bsd.h \ diff --git a/deps/uv/src/unix/darwin-proctitle.c b/deps/uv/src/unix/darwin-proctitle.c index e6c85905c..c3171a617 100644 --- a/deps/uv/src/unix/darwin-proctitle.c +++ b/deps/uv/src/unix/darwin-proctitle.c @@ -18,11 +18,18 @@ * IN THE SOFTWARE. */ -#include <CoreFoundation/CoreFoundation.h> -#include <ApplicationServices/ApplicationServices.h> +#include <TargetConditionals.h> + +#if !TARGET_OS_IPHONE +# include <CoreFoundation/CoreFoundation.h> +# include <ApplicationServices/ApplicationServices.h> +#endif int uv__set_process_title(const char* title) { +#if TARGET_OS_IPHONE + return -1; +#else typedef CFTypeRef (*LSGetCurrentApplicationASNType)(void); typedef OSStatus (*LSSetApplicationInformationItemType)(int, CFTypeRef, @@ -76,4 +83,5 @@ int uv__set_process_title(const char* title) { NULL); return (err == noErr) ? 0 : -1; +#endif /* !TARGET_OS_IPHONE */ } diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c index a6145790a..3d7ade60d 100644 --- a/deps/uv/src/unix/pipe.c +++ b/deps/uv/src/unix/pipe.c @@ -45,12 +45,10 @@ int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) { int uv_pipe_bind(uv_pipe_t* handle, const char* name) { struct sockaddr_un saddr; const char* pipe_fname; - int saved_errno; int sockfd; int status; int bound; - saved_errno = errno; pipe_fname = NULL; sockfd = -1; status = -1; @@ -105,35 +103,22 @@ out: free((void*)pipe_fname); } - errno = saved_errno; return status; } int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { - int saved_errno; - int status; - - saved_errno = errno; - status = -1; + if (uv__stream_fd(handle) == -1) + return uv__set_artificial_error(handle->loop, UV_EINVAL); - if (uv__stream_fd(handle) == -1) { - uv__set_artificial_error(handle->loop, UV_EINVAL); - goto out; - } assert(uv__stream_fd(handle) >= 0); + if (listen(uv__stream_fd(handle), backlog)) + return uv__set_sys_error(handle->loop, errno); - if ((status = listen(uv__stream_fd(handle), backlog)) == -1) { - uv__set_sys_error(handle->loop, errno); - } else { - handle->connection_cb = cb; - handle->io_watcher.cb = uv__pipe_accept; - uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN); - } - -out: - errno = saved_errno; - return status; + handle->connection_cb = cb; + handle->io_watcher.cb = uv__pipe_accept; + uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN); + return 0; } @@ -171,12 +156,10 @@ void uv_pipe_connect(uv_connect_t* req, const char* name, uv_connect_cb cb) { struct sockaddr_un saddr; - int saved_errno; int new_sock; int err; int r; - saved_errno = errno; new_sock = (uv__stream_fd(handle) == -1); err = -1; @@ -223,19 +206,15 @@ out: /* Mimic the Windows pipe implementation, always * return 0 and let the callback handle errors. */ - errno = saved_errno; } /* TODO merge with uv__server_io()? */ static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, unsigned int events) { uv_pipe_t* pipe; - int saved_errno; int sockfd; - saved_errno = errno; pipe = container_of(w, uv_pipe_t, io_watcher); - assert(pipe->type == UV_NAMED_PIPE); sockfd = uv__accept(uv__stream_fd(pipe)); @@ -252,8 +231,6 @@ static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, unsigned int events) { uv__io_stop(pipe->loop, &pipe->io_watcher, UV__POLLIN); } } - - errno = saved_errno; } diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 0c38231d6..1e97625eb 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -536,42 +536,30 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { int uv_accept(uv_stream_t* server, uv_stream_t* client) { - uv_stream_t* streamServer; - uv_stream_t* streamClient; - int saved_errno; - int status; - /* TODO document this */ assert(server->loop == client->loop); - saved_errno = errno; - status = -1; - - streamServer = (uv_stream_t*)server; - streamClient = (uv_stream_t*)client; - - if (streamServer->accepted_fd < 0) { - uv__set_sys_error(server->loop, EAGAIN); - goto out; - } + if (server->accepted_fd == -1) + return uv__set_sys_error(server->loop, EAGAIN); - switch (streamClient->type) { + switch (client->type) { case UV_NAMED_PIPE: case UV_TCP: - if (uv__stream_open(streamClient, streamServer->accepted_fd, - UV_STREAM_READABLE | UV_STREAM_WRITABLE)) { + if (uv__stream_open(client, + server->accepted_fd, + UV_STREAM_READABLE | UV_STREAM_WRITABLE)) { /* TODO handle error */ - close(streamServer->accepted_fd); - streamServer->accepted_fd = -1; - goto out; + close(server->accepted_fd); + server->accepted_fd = -1; + return -1; } break; case UV_UDP: - if (uv_udp_open((uv_udp_t*) client, streamServer->accepted_fd)) { - close(streamServer->accepted_fd); - streamServer->accepted_fd = -1; - goto out; + if (uv_udp_open((uv_udp_t*) client, server->accepted_fd)) { + close(server->accepted_fd); + server->accepted_fd = -1; + return -1; } break; @@ -579,13 +567,9 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) { assert(0); } - uv__io_start(streamServer->loop, &streamServer->io_watcher, UV__POLLIN); - streamServer->accepted_fd = -1; - status = 0; - -out: - errno = saved_errno; - return status; + uv__io_start(server->loop, &server->io_watcher, UV__POLLIN); + server->accepted_fd = -1; + return 0; } diff --git a/deps/uv/src/unix/tcp.c b/deps/uv/src/unix/tcp.c index 1ed69d63c..2c81ff087 100644 --- a/deps/uv/src/unix/tcp.c +++ b/deps/uv/src/unix/tcp.c @@ -151,77 +151,47 @@ int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) { } -int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name, - int* namelen) { +int uv_tcp_getsockname(uv_tcp_t* handle, + struct sockaddr* name, + int* namelen) { socklen_t socklen; - int saved_errno; - int rv = 0; - /* Don't clobber errno. */ - saved_errno = errno; + if (handle->delayed_error) + return uv__set_sys_error(handle->loop, handle->delayed_error); - if (handle->delayed_error) { - uv__set_sys_error(handle->loop, handle->delayed_error); - rv = -1; - goto out; - } - - if (uv__stream_fd(handle) < 0) { - uv__set_sys_error(handle->loop, EINVAL); - rv = -1; - goto out; - } + if (uv__stream_fd(handle) < 0) + return uv__set_sys_error(handle->loop, EINVAL); /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t)*namelen; + socklen = (socklen_t) *namelen; - if (getsockname(uv__stream_fd(handle), name, &socklen) == -1) { - uv__set_sys_error(handle->loop, errno); - rv = -1; - } else { - *namelen = (int)socklen; - } + if (getsockname(uv__stream_fd(handle), name, &socklen) == -1) + return uv__set_sys_error(handle->loop, errno); -out: - errno = saved_errno; - return rv; + *namelen = (int) socklen; + return 0; } -int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name, - int* namelen) { +int uv_tcp_getpeername(uv_tcp_t* handle, + struct sockaddr* name, + int* namelen) { socklen_t socklen; - int saved_errno; - int rv = 0; - /* Don't clobber errno. */ - saved_errno = errno; - - if (handle->delayed_error) { - uv__set_sys_error(handle->loop, handle->delayed_error); - rv = -1; - goto out; - } + if (handle->delayed_error) + return uv__set_sys_error(handle->loop, handle->delayed_error); - if (uv__stream_fd(handle) < 0) { - uv__set_sys_error(handle->loop, EINVAL); - rv = -1; - goto out; - } + if (uv__stream_fd(handle) < 0) + return uv__set_sys_error(handle->loop, EINVAL); /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t)*namelen; + socklen = (socklen_t) *namelen; - if (getpeername(uv__stream_fd(handle), name, &socklen) == -1) { - uv__set_sys_error(handle->loop, errno); - rv = -1; - } else { - *namelen = (int)socklen; - } + if (getpeername(uv__stream_fd(handle), name, &socklen) == -1) + return uv__set_sys_error(handle->loop, errno); -out: - errno = saved_errno; - return rv; + *namelen = (int) socklen; + return 0; } @@ -259,14 +229,7 @@ int uv__tcp_connect(uv_connect_t* req, uv_tcp_t* handle, struct sockaddr_in addr, uv_connect_cb cb) { - int saved_errno; - int status; - - saved_errno = errno; - status = uv__connect(req, handle, (struct sockaddr*)&addr, sizeof addr, cb); - errno = saved_errno; - - return status; + return uv__connect(req, handle, (struct sockaddr*) &addr, sizeof addr, cb); } @@ -274,14 +237,7 @@ int uv__tcp_connect6(uv_connect_t* req, uv_tcp_t* handle, struct sockaddr_in6 addr, uv_connect_cb cb) { - int saved_errno; - int status; - - saved_errno = errno; - status = uv__connect(req, handle, (struct sockaddr*)&addr, sizeof addr, cb); - errno = saved_errno; - - return status; + return uv__connect(req, handle, (struct sockaddr*) &addr, sizeof addr, cb); } diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index 994cdf21a..b19aebce9 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -291,36 +291,27 @@ static int uv__bind(uv_udp_t* handle, struct sockaddr* addr, socklen_t len, unsigned flags) { - int saved_errno; - int status; int yes; int fd; - saved_errno = errno; - status = -1; fd = -1; /* Check for bad flags. */ - if (flags & ~UV_UDP_IPV6ONLY) { - uv__set_sys_error(handle->loop, EINVAL); - goto out; - } + if (flags & ~UV_UDP_IPV6ONLY) + return uv__set_sys_error(handle->loop, EINVAL); /* Cannot set IPv6-only mode on non-IPv6 socket. */ - if ((flags & UV_UDP_IPV6ONLY) && domain != AF_INET6) { - uv__set_sys_error(handle->loop, EINVAL); - goto out; - } + if ((flags & UV_UDP_IPV6ONLY) && domain != AF_INET6) + return uv__set_sys_error(handle->loop, EINVAL); - if (handle->io_watcher.fd == -1) { - if ((fd = uv__socket(domain, SOCK_DGRAM, 0)) == -1) { - uv__set_sys_error(handle->loop, errno); - goto out; - } + fd = handle->io_watcher.fd; + if (fd == -1) { + fd = uv__socket(domain, SOCK_DGRAM, 0); + if (fd == -1) + return uv__set_sys_error(handle->loop, errno); handle->io_watcher.fd = fd; } - fd = handle->io_watcher.fd; yes = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes) == -1) { uv__set_sys_error(handle->loop, errno); @@ -361,17 +352,12 @@ static int uv__bind(uv_udp_t* handle, goto out; } - handle->io_watcher.fd = fd; - status = 0; + return 0; out: - if (status) { - close(handle->io_watcher.fd); - handle->io_watcher.fd = -1; - } - - errno = saved_errno; - return status; + close(handle->io_watcher.fd); + handle->io_watcher.fd = -1; + return -1; } @@ -479,24 +465,15 @@ int uv__udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned flags) { int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { - int saved_errno; - int status; int yes; - saved_errno = errno; - status = -1; - /* Check for already active socket. */ - if (handle->io_watcher.fd != -1) { - uv__set_artificial_error(handle->loop, UV_EALREADY); - goto out; - } + if (handle->io_watcher.fd != -1) + return uv__set_artificial_error(handle->loop, UV_EALREADY); yes = 1; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes) == -1) { - uv__set_sys_error(handle->loop, errno); - goto out; - } + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes) == -1) + return uv__set_sys_error(handle->loop, errno); /* On the BSDs, SO_REUSEADDR lets you reuse an address that's in the TIME_WAIT * state (i.e. was until recently tied to a socket) while SO_REUSEPORT lets @@ -508,18 +485,12 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { */ #ifdef SO_REUSEPORT yes = 1; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof yes) == -1) { - uv__set_sys_error(handle->loop, errno); - goto out; - } + if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof yes) == -1) + return uv__set_sys_error(handle->loop, errno); #endif handle->io_watcher.fd = sock; - status = 0; - -out: - errno = saved_errno; - return status; + return 0; } @@ -616,31 +587,18 @@ int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) { int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen) { socklen_t socklen; - int saved_errno; - int rv = 0; - /* Don't clobber errno. */ - saved_errno = errno; - - if (handle->io_watcher.fd == -1) { - uv__set_sys_error(handle->loop, EINVAL); - rv = -1; - goto out; - } + if (handle->io_watcher.fd == -1) + return uv__set_sys_error(handle->loop, EINVAL); /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t)*namelen; + socklen = (socklen_t) *namelen; - if (getsockname(handle->io_watcher.fd, name, &socklen) == -1) { - uv__set_sys_error(handle->loop, errno); - rv = -1; - } else { - *namelen = (int)socklen; - } + if (getsockname(handle->io_watcher.fd, name, &socklen) == -1) + return uv__set_sys_error(handle->loop, errno); -out: - errno = saved_errno; - return rv; + *namelen = (int) socklen; + return 0; } diff --git a/deps/uv/src/version.c b/deps/uv/src/version.c index 0d502d01b..e92126ffa 100644 --- a/deps/uv/src/version.c +++ b/deps/uv/src/version.c @@ -24,12 +24,14 @@ /* * Versions with an even minor version (e.g. 0.6.1 or 1.0.4) are API and ABI * stable. When the minor version is odd, the API can change between patch - * releases. + * releases. Make sure you update the -soname directives in config-unix.mk + * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but + * not UV_VERSION_PATCH.) */ #define UV_VERSION_MAJOR 0 #define UV_VERSION_MINOR 11 -#define UV_VERSION_PATCH 2 +#define UV_VERSION_PATCH 3 #define UV_VERSION_IS_RELEASE 1 diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c index c5649d3ae..8ef420e67 100644 --- a/deps/uv/src/win/process.c +++ b/deps/uv/src/win/process.c @@ -45,6 +45,36 @@ typedef struct env_var { #define E_V(str) { str "=", L##str, sizeof(str), 0, 0 } +static HANDLE uv_global_job_handle_; +static uv_once_t uv_global_job_handle_init_guard_ = UV_ONCE_INIT; + + +static void uv__init_global_job_handle() { + SECURITY_ATTRIBUTES attr; + JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; + + memset(&attr, 0, sizeof attr); + attr.bInheritHandle = FALSE; + + memset(&info, 0, sizeof info); + info.BasicLimitInformation.LimitFlags = + JOB_OBJECT_LIMIT_BREAKAWAY_OK | + JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK | + JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION | + JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; + + uv_global_job_handle_ = CreateJobObjectW(&attr, NULL); + if (uv_global_job_handle_ == NULL) + uv_fatal_error(GetLastError(), "CreateJobObjectW"); + + if (!SetInformationJobObject(uv_global_job_handle_, + JobObjectExtendedLimitInformation, + &info, + sizeof info)) + uv_fatal_error(GetLastError(), "SetInformationJobObject"); +} + + static uv_err_t uv_utf8_to_utf16_alloc(const char* s, WCHAR** ws_ptr) { int ws_len, r; WCHAR* ws; @@ -908,6 +938,15 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, process->process_handle = info.hProcess; process->pid = info.dwProcessId; + /* If the process isn't spawned as detached, assign to the global job */ + /* object so windows will kill it when the parent process dies. */ + if (!(options.flags & UV_PROCESS_DETACHED)) { + uv_once(&uv_global_job_handle_init_guard_, uv__init_global_job_handle); + + if (!AssignProcessToJobObject(uv_global_job_handle_, info.hProcess)) + uv_fatal_error(GetLastError(), "AssignProcessToJobObject"); + } + /* Set IPC pid to all IPC pipes. */ for (i = 0; i < options.stdio_count; i++) { const uv_stdio_container_t* fdopt = &options.stdio[i]; diff --git a/deps/uv/test/test-process-title.c b/deps/uv/test/test-process-title.c index 13d9dddfc..c870abd15 100644 --- a/deps/uv/test/test-process-title.c +++ b/deps/uv/test/test-process-title.c @@ -42,8 +42,12 @@ static void set_title(const char* title) { TEST_IMPL(process_title) { +#if defined(__sun) + RETURN_SKIP("uv_(get|set)_process_title is not implemented."); +#else /* Check for format string vulnerabilities. */ - set_title("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"); + set_title("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"); set_title("new title"); return 0; +#endif } diff --git a/deps/uv/test/test-tty.c b/deps/uv/test/test-tty.c index eb5d5df52..f3003efa6 100644 --- a/deps/uv/test/test-tty.c +++ b/deps/uv/test/test-tty.c @@ -30,6 +30,9 @@ # include <unistd.h> #endif +#include <string.h> +#include <errno.h> + TEST_IMPL(tty) { int r, width, height; @@ -62,7 +65,12 @@ TEST_IMPL(tty) { #else /* unix */ ttyin_fd = open("/dev/tty", O_RDONLY, 0); + if (ttyin_fd < 0) + LOGF("Cannot open /dev/tty as read-only: %s\n", strerror(errno)); + ttyout_fd = open("/dev/tty", O_WRONLY, 0); + if (ttyout_fd < 0) + LOGF("Cannot open /dev/tty as write-only: %s\n", strerror(errno)); #endif ASSERT(ttyin_fd >= 0); diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index f2cdd538d..2e228855a 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -165,9 +165,16 @@ ], }, 'conditions': [ - ['"<(library)" == "shared_library"', { + ['library=="shared_library"', { 'cflags': [ '-fPIC' ], }], + ['library=="shared_library" and OS!="mac"', { + 'link_settings': { + # Must correspond with UV_VERSION_MAJOR and UV_VERSION_MINOR + # in src/version.c + 'libraries': [ '-Wl,-soname,libuv.so.0.11' ], + }, + }], ], }], [ 'OS=="linux" or OS=="mac"', { |