Exemple #1
0
static void detach_cb(uv_process_t* process, int exit_status, int term_signal) {
  uv_err_t err;
  printf("detach_cb\n");
  exit_cb_called++;
  ASSERT(exit_status == 0);
  uv_close((uv_handle_t*)process, close_cb);

  /*
   * Unlike other tests, this one needs to make sure the process *is*
   * still alive.
   */
  err = uv_kill(process->pid, 0);
  ASSERT(err.code == 0);
  err = uv_kill(process->pid, 15);
  ASSERT(err.code == 0);
}
Exemple #2
0
static void kill_cb(uv_process_t* process,
                    int64_t exit_status,
                    int term_signal) {
  int err;

  printf("exit_cb\n");
  exit_cb_called++;
#ifdef _WIN32
  ASSERT(exit_status == 1);
#else
  ASSERT(exit_status == 0);
#endif
#if defined(__APPLE__) || defined(__MVS__)
  /*
   * At least starting with Darwin Kernel Version 16.4.0, sending a SIGTERM to a
   * process that is still starting up kills it with SIGKILL instead of SIGTERM.
   * See: https://github.com/libuv/libuv/issues/1226
   */
  ASSERT(no_term_signal || term_signal == SIGTERM || term_signal == SIGKILL);
#else
  ASSERT(no_term_signal || term_signal == SIGTERM);
#endif
  uv_close((uv_handle_t*)process, close_cb);

  /*
   * Sending signum == 0 should check if the
   * child process is still alive, not kill it.
   * This process should be dead.
   */
  err = uv_kill(process->pid, 0);
  ASSERT(err == UV_ESRCH);
}
Exemple #3
0
static int luv_kill(lua_State* L) {
  int pid = luaL_checkinteger(L, 1);
  int signum = luv_parse_signal(L, 2);
  int ret = uv_kill(pid, signum);
  if (ret < 0) return luv_error(L, ret);
  lua_pushinteger(L, ret);
  return 1;
}
Exemple #4
0
static int LuaIO_process_kill(lua_State* L) {
  int pid = luaL_checkinteger(L, 1);
  int argc = lua_gettop(L);
  int signal = SIGTERM;

  if(argc == 2) signal = luaL_checkinteger(L, 2);
  int err = uv_kill(pid, signal);
  if (err < 0) return luaL_error(L, "process.kill(pid[, signal]) uv_kill() error: %s\n", uv_strerror(err));

  return 0;
}
Exemple #5
0
/*
 * Class:     com_iwebpp_libuvpp_LibUV
 * Method:    _kill
 * Signature: (II)I
 */
extern "C" JNIEXPORT  jint JNICALL Java_com_iwebpp_libuvpp_LibUV__1kill
(JNIEnv *env, jclass cls, jint pid, jint signal) {

    uv_err_t err = uv_kill(pid, signal);
    if (err.code != UV_OK) {
        errno = err.code;
        return -1;
    }

    return 0;
}
void destroyInstance(void* userData)
{
    PluginData* plugin = (PluginData*)userData;

    if (plugin->process.pid > 0)
		uv_kill(plugin->process.pid, 2);

    if (plugin->conn)
        VICEConnection_destroy(plugin->conn);

    free(plugin);
}
void destroy_instance(void* user_data) {
    PluginData* plugin = (PluginData*)user_data;

    if (plugin->process.pid > 0) {
        uv_kill(plugin->process.pid, 2);
	}

    if (plugin->conn) {
        VICEConnection_destroy(plugin->conn);
	}

    free(plugin);
}
Exemple #8
0
/// Iterates the table, sending SIGTERM to stopped jobs and SIGKILL to those
/// that didn't die from SIGTERM after a while(exit_timeout is 0).
static void job_stop_timer_cb(uv_timer_t *handle)
{
  Job *job;
  uint64_t now = os_hrtime();

  for (size_t i = 0; i < MAX_RUNNING_JOBS; i++) {
    if ((job = table[i]) == NULL || !job->stopped_time) {
      continue;
    }

    uint64_t elapsed = now - job->stopped_time;

    if (!job->term_sent && elapsed >= TERM_TIMEOUT) {
      ILOG("Sending SIGTERM to job(id: %d)", job->id);
      uv_kill(job->pid, SIGTERM);
      job->term_sent = true;
    } else if (elapsed >= KILL_TIMEOUT) {
      ILOG("Sending SIGKILL to job(id: %d)", job->id);
      uv_kill(job->pid, SIGKILL);
      process_close(job);
    }
  }
}
Exemple #9
0
/// Releases job control resources and terminates running jobs
void job_teardown(void)
{
  // Stop all jobs
  for (int i = 0; i < MAX_RUNNING_JOBS; i++) {
    Job *job;
    if ((job = table[i]) != NULL) {
      uv_kill(job->pid, SIGTERM);
      job->term_sent = true;
      job_stop(job);
    }
  }

  // Wait until all jobs are closed
  event_poll_until(-1, !stop_requests);
  uv_signal_stop(&schld);
  uv_close((uv_handle_t *)&schld, NULL);
  // Close the timer
  uv_close((uv_handle_t *)&job_stop_timer, NULL);
}
Exemple #10
0
static void kill_cb(uv_process_t* process, int exit_status, int term_signal) {
  uv_err_t err;

  printf("exit_cb\n");
  exit_cb_called++;
#ifdef _WIN32
  ASSERT(exit_status == 1);
#else
  ASSERT(exit_status == 0);
#endif
  ASSERT(no_term_signal || term_signal == 15);
  uv_close((uv_handle_t*)process, close_cb);

  /* Sending signum == 0 should check if the
   * child process is still alive, not kill it.
   */
  err = uv_kill(process->pid, 0);
  ASSERT(err.code != UV_OK);
}
Exemple #11
0
int uv_process_kill(uv_process_t* process, int signum) {
  return uv_kill(process->pid, signum);
}
Exemple #12
0
 /**
  * @brief kill Sends the specified signal to the given PID.
  * @param pid A valid process id.
  * @param signum A valid signal identifier.
  * @return True in case of success, false otherwise.
  */
 static bool kill(int pid, int signum) noexcept {
     return (0 == uv_kill(pid, signum));
 }