< prev index next >

src/java.base/unix/native/libnio/ch/NativeThread.c

Print this page




  60 JNIEXPORT void JNICALL
  61 Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
  62 {
  63     /* Install the null handler for INTERRUPT_SIGNAL.  This might overwrite the
  64      * handler previously installed by <platform>_close.c, but that's okay
  65      * since neither handler actually does anything.  We install our own
  66      * handler here simply out of paranoia; ultimately the two mechanisms
  67      * should somehow be unified, perhaps within the VM.
  68      */
  69 
  70     sigset_t ss;
  71     struct sigaction sa, osa;
  72     sa.sa_handler = nullHandler;
  73     sa.sa_flags = 0;
  74     sigemptyset(&sa.sa_mask);
  75     if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0)
  76         JNU_ThrowIOExceptionWithLastError(env, "sigaction");
  77 }
  78 
  79 JNIEXPORT jlong JNICALL
  80 Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
  81 {
  82 #ifdef __solaris__
  83     return (jlong)thr_self();
  84 #else
  85     return (jlong)pthread_self();
  86 #endif
  87 }
  88 
  89 JNIEXPORT void JNICALL
  90 Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
  91 {
  92     int ret;
  93 #ifdef __solaris__
  94     ret = thr_kill((thread_t)thread, INTERRUPT_SIGNAL);
  95 #else
  96     ret = pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL);
  97 #endif
  98 #ifdef MACOSX
  99     if (ret != 0 && ret != ESRCH)
 100 #else
 101     if (ret != 0)
 102 #endif
 103         JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed");
 104 }


  60 JNIEXPORT void JNICALL
  61 Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
  62 {
  63     /* Install the null handler for INTERRUPT_SIGNAL.  This might overwrite the
  64      * handler previously installed by <platform>_close.c, but that's okay
  65      * since neither handler actually does anything.  We install our own
  66      * handler here simply out of paranoia; ultimately the two mechanisms
  67      * should somehow be unified, perhaps within the VM.
  68      */
  69 
  70     sigset_t ss;
  71     struct sigaction sa, osa;
  72     sa.sa_handler = nullHandler;
  73     sa.sa_flags = 0;
  74     sigemptyset(&sa.sa_mask);
  75     if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0)
  76         JNU_ThrowIOExceptionWithLastError(env, "sigaction");
  77 }
  78 
  79 JNIEXPORT jlong JNICALL
  80 Java_sun_nio_ch_NativeThread_current0(JNIEnv *env, jclass cl)
  81 {
  82 #ifdef __solaris__
  83     return (jlong)thr_self();
  84 #else
  85     return (jlong)pthread_self();
  86 #endif
  87 }
  88 
  89 JNIEXPORT void JNICALL
  90 Java_sun_nio_ch_NativeThread_signal0(JNIEnv *env, jclass cl, jlong thread)
  91 {
  92     int ret;
  93 #ifdef __solaris__
  94     ret = thr_kill((thread_t)thread, INTERRUPT_SIGNAL);
  95 #else
  96     ret = pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL);
  97 #endif
  98 #ifdef MACOSX
  99     if (ret != 0 && ret != ESRCH)
 100 #else
 101     if (ret != 0)
 102 #endif
 103         JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed");
 104 }
< prev index next >