< prev index next >

src/os/linux/vm/os_linux.cpp

Print this page
rev 8847 : 8140482: Various minor code improvements (runtime)
Reviewed-by: dholmes, coleenp, sspitsyn, dsamersoff


4629   }
4630   return NULL;
4631 }
4632 
4633 void os::Linux::save_preinstalled_handler(int sig, struct sigaction& oldAct) {
4634   assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
4635   sigact[sig] = oldAct;
4636   sigs |= (unsigned int)1 << sig;
4637 }
4638 
4639 // for diagnostic
4640 int os::Linux::sigflags[MAXSIGNUM];
4641 
4642 int os::Linux::get_our_sigflags(int sig) {
4643   assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
4644   return sigflags[sig];
4645 }
4646 
4647 void os::Linux::set_our_sigflags(int sig, int flags) {
4648   assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");

4649   sigflags[sig] = flags;

4650 }
4651 
4652 void os::Linux::set_signal_handler(int sig, bool set_installed) {
4653   // Check for overwrite.
4654   struct sigaction oldAct;
4655   sigaction(sig, (struct sigaction*)NULL, &oldAct);
4656 
4657   void* oldhand = oldAct.sa_sigaction
4658                 ? CAST_FROM_FN_PTR(void*,  oldAct.sa_sigaction)
4659                 : CAST_FROM_FN_PTR(void*,  oldAct.sa_handler);
4660   if (oldhand != CAST_FROM_FN_PTR(void*, SIG_DFL) &&
4661       oldhand != CAST_FROM_FN_PTR(void*, SIG_IGN) &&
4662       oldhand != CAST_FROM_FN_PTR(void*, (sa_sigaction_t)signalHandler)) {
4663     if (AllowUserSignalHandlers || !set_installed) {
4664       // Do not overwrite; user takes responsibility to forward to us.
4665       return;
4666     } else if (UseSignalChaining) {
4667       // save the old handler in jvm
4668       save_preinstalled_handler(sig, oldAct);
4669       // libjsig also interposes the sigaction() call below and saves the




4629   }
4630   return NULL;
4631 }
4632 
4633 void os::Linux::save_preinstalled_handler(int sig, struct sigaction& oldAct) {
4634   assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
4635   sigact[sig] = oldAct;
4636   sigs |= (unsigned int)1 << sig;
4637 }
4638 
4639 // for diagnostic
4640 int os::Linux::sigflags[MAXSIGNUM];
4641 
4642 int os::Linux::get_our_sigflags(int sig) {
4643   assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
4644   return sigflags[sig];
4645 }
4646 
4647 void os::Linux::set_our_sigflags(int sig, int flags) {
4648   assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
4649   if (sig > 0 && sig < MAXSIGNUM) {
4650     sigflags[sig] = flags;
4651   }
4652 }
4653 
4654 void os::Linux::set_signal_handler(int sig, bool set_installed) {
4655   // Check for overwrite.
4656   struct sigaction oldAct;
4657   sigaction(sig, (struct sigaction*)NULL, &oldAct);
4658 
4659   void* oldhand = oldAct.sa_sigaction
4660                 ? CAST_FROM_FN_PTR(void*,  oldAct.sa_sigaction)
4661                 : CAST_FROM_FN_PTR(void*,  oldAct.sa_handler);
4662   if (oldhand != CAST_FROM_FN_PTR(void*, SIG_DFL) &&
4663       oldhand != CAST_FROM_FN_PTR(void*, SIG_IGN) &&
4664       oldhand != CAST_FROM_FN_PTR(void*, (sa_sigaction_t)signalHandler)) {
4665     if (AllowUserSignalHandlers || !set_installed) {
4666       // Do not overwrite; user takes responsibility to forward to us.
4667       return;
4668     } else if (UseSignalChaining) {
4669       // save the old handler in jvm
4670       save_preinstalled_handler(sig, oldAct);
4671       // libjsig also interposes the sigaction() call below and saves the


< prev index next >