Merge branch 'v0.10'

Conflicts:
	src/unix/process.c
This commit is contained in:
Fedor Indutny 2014-03-26 20:45:13 +04:00
commit c84796ecc2
3 changed files with 35 additions and 1 deletions

View File

@ -316,7 +316,7 @@ static void uv__process_child_init(const uv_process_options_t* options,
if (fd <= 2)
uv__nonblock(fd, 0);
if (close_fd != -1)
if (close_fd >= stdio_count)
uv__close(close_fd);
}

View File

@ -177,6 +177,7 @@ TEST_DECLARE (spawn_setgid_fails)
TEST_DECLARE (spawn_stdout_to_file)
TEST_DECLARE (spawn_stdout_and_stderr_to_file)
TEST_DECLARE (spawn_auto_unref)
TEST_DECLARE (spawn_closed_process_io)
TEST_DECLARE (fs_poll)
TEST_DECLARE (fs_poll_getpath)
TEST_DECLARE (kill)
@ -480,6 +481,7 @@ TASK_LIST_START
TEST_ENTRY (spawn_stdout_to_file)
TEST_ENTRY (spawn_stdout_and_stderr_to_file)
TEST_ENTRY (spawn_auto_unref)
TEST_ENTRY (spawn_closed_process_io)
TEST_ENTRY (fs_poll)
TEST_ENTRY (fs_poll_getpath)
TEST_ENTRY (kill)

View File

@ -680,6 +680,38 @@ TEST_IMPL(spawn_same_stdout_stderr) {
}
TEST_IMPL(spawn_closed_process_io) {
uv_pipe_t in;
uv_write_t write_req;
uv_buf_t buf;
uv_stdio_container_t stdio[2];
static char buffer[] = "hello-from-spawn_stdin";
init_process_options("spawn_helper1", exit_cb);
uv_pipe_init(uv_default_loop(), &in, 0);
options.stdio = stdio;
options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
options.stdio[0].data.stream = (uv_stream_t*) &in;
options.stdio_count = 1;
close(0); /* Close process stdin. */
ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options));
buf = uv_buf_init(buffer, sizeof(buffer));
ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb));
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
ASSERT(exit_cb_called == 1);
ASSERT(close_cb_called == 2); /* process, child stdin */
MAKE_VALGRIND_HAPPY();
return 0;
}
TEST_IMPL(kill) {
int r;