示例#1
0
JNIEXPORT void 
JNICALL Java_us_temerity_pipeline_NativeProcessLight_signalNative
(
 JNIEnv *env, 
 jobject obj, 
 jint signal,  /* IN: POSIX signal */ 
 jint pid      /* IN: POSIX signal */ 
 )
{
  /* exception initialization */ 
  jclass IOException = env->FindClass("java/io/IOException");
  char msg[1024];
  if(IOException == 0) {
    errno = EINVAL;
    perror("NativeProcessLight.signalNative(), unable to lookup \"java/lang/IOException\"");
    return;
  }

  /* kill the process */ 
  switch(signal) {
  case 9:  /* SIGKILL */
    if(!KillProcessEx((DWORD) pid, TRUE)) {
      sprintf(msg, "failed send signal (%d) to process (%d)", signal, pid);
      env->ThrowNew(IOException, msg);
      return; 
    }
    break;

  default:
    sprintf(msg, "signal (%d) not supported for Windows processes", pid);
    env->ThrowNew(IOException, msg);
    return;
  }
}
示例#2
0
JNIEXPORT jboolean JNICALL Java_org_jvnet_winp_Native_kill(JNIEnv* env, jclass clazz, jint pid, jboolean recursive) {
	return KillProcessEx(pid, recursive);
}