Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

unix: auto-unref spawn handle on process exit

Consistent, for better or worse, with uv-win.

Fixes #718.
  • Loading branch information...
commit da0b84d4e8408a6f92147d8127b01b3274215444 1 parent 3348cd7
@bnoordhuis bnoordhuis authored
Showing with 17 additions and 0 deletions.
  1. +2 −0  src/unix/process.c
  2. +2 −0  test/test-list.h
  3. +13 −0 test/test-spawn.c
View
2  src/unix/process.c
@@ -89,6 +89,8 @@ static void uv__chld(uv_signal_t* handle, int signum) {
if (process == NULL)
continue; /* XXX bug? abort? */
+ uv__handle_stop(process);
+
if (process->exit_cb == NULL)
continue;
View
2  test/test-list.h
@@ -152,6 +152,7 @@ TEST_DECLARE (spawn_preserve_env)
TEST_DECLARE (spawn_setuid_fails)
TEST_DECLARE (spawn_setgid_fails)
TEST_DECLARE (spawn_stdout_to_file)
+TEST_DECLARE (spawn_auto_unref)
TEST_DECLARE (fs_poll)
TEST_DECLARE (kill)
TEST_DECLARE (fs_file_noent)
@@ -413,6 +414,7 @@ TASK_LIST_START
TEST_ENTRY (spawn_setuid_fails)
TEST_ENTRY (spawn_setgid_fails)
TEST_ENTRY (spawn_stdout_to_file)
+ TEST_ENTRY (spawn_auto_unref)
TEST_ENTRY (fs_poll)
TEST_ENTRY (kill)
View
13 test/test-spawn.c
@@ -923,3 +923,16 @@ TEST_IMPL(spawn_setgid_fails) {
return 0;
}
#endif
+
+
+TEST_IMPL(spawn_auto_unref) {
+ init_process_options("spawn_helper1", NULL);
+ ASSERT(0 == uv_spawn(uv_default_loop(), &process, options));
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
+ ASSERT(0 == uv_is_closing((uv_handle_t*) &process));
+ uv_close((uv_handle_t*) &process, NULL);
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
+ ASSERT(0 != uv_is_closing((uv_handle_t*) &process));
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.