Skip to content

[os x] killing freshly started processes is unreliable #1226

@bnoordhuis

Description

@bnoordhuis

Sending a SIGTERM to a process that is still starting up kills it with SIGKILL on my OS X machine, not SIGTERM. It's making the kill test fail reliably for me locally.

Demonstrated with this patch:

diff --git a/test/test-spawn.c b/test/test-spawn.c
index 53a0369..6676101 100644
--- a/test/test-spawn.c
+++ b/test/test-spawn.c
@@ -90,6 +90,8 @@ static void kill_cb(uv_process_t* process,
 #else
   ASSERT(exit_status == 0);
 #endif
+  printf("no_term_signal=%d term_signal=%d exit_status=%d\n",
+         no_term_signal, term_signal, (int) exit_status);
   ASSERT(no_term_signal || term_signal == 15);
   uv_close((uv_handle_t*)process, close_cb);
 

When you run the test:

$ uname -a
Darwin hermes.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

$ out/Debug/run-tests kill
not ok 1 - kill
# exit code 6
# Output from process `kill`:
# exit_cb
# no_term_signal=0 term_signal=9 exit_status=0
# Assertion failed in ../test/test-spawn.c on line 95: no_term_signal || term_signal == 15

Adding a small delay avoids it:

diff --git a/test/test-spawn.c b/test/test-spawn.c
index 53a0369..6676101 100644
--- a/test/test-spawn.c
+++ b/test/test-spawn.c
@@ -920,6 +922,7 @@ TEST_IMPL(kill) {
 
   r = uv_spawn(uv_default_loop(), &process, &options);
   ASSERT(r == 0);
+  usleep(1000);
 
   /* Sending signum == 0 should check if the
    * child process is still alive, not kill it.

Interestingly, sending a different signal works okay too (SIGINT here but e.g. SIGQUIT works too):

diff --git a/test/test-spawn.c b/test/test-spawn.c
index 53a0369..33467f6 100644
--- a/test/test-spawn.c
+++ b/test/test-spawn.c
@@ -90,7 +90,7 @@ static void kill_cb(uv_process_t* process,
 #else
   ASSERT(exit_status == 0);
 #endif
-  ASSERT(no_term_signal || term_signal == 15);
+  ASSERT(no_term_signal || term_signal == 15 || term_signal == SIGINT);
   uv_close((uv_handle_t*)process, close_cb);
 
   /*
@@ -930,7 +930,7 @@ TEST_IMPL(kill) {
   ASSERT(r == 0);
 
   /* Kill the process. */
-  r = uv_kill(process.pid, /* SIGTERM */ 15);
+  r = uv_kill(process.pid, SIGINT);
   ASSERT(r == 0);
 
   r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions