< prev index next >

src/hotspot/os/bsd/os_bsd.cpp

Print this page




 516 #undef EXTENSIONS_DIR
 517 }
 518 
 519 ////////////////////////////////////////////////////////////////////////////////
 520 // breakpoint support
 521 
 522 void os::breakpoint() {
 523   BREAKPOINT;
 524 }
 525 
 526 extern "C" void breakpoint() {
 527   // use debugger to set breakpoint here
 528 }
 529 
 530 ////////////////////////////////////////////////////////////////////////////////
 531 // signal support
 532 
 533 debug_only(static bool signal_sets_initialized = false);
 534 static sigset_t unblocked_sigs, vm_sigs;
 535 
 536 bool os::Bsd::is_sig_ignored(int sig) {
 537   struct sigaction oact;
 538   sigaction(sig, (struct sigaction*)NULL, &oact);
 539   void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
 540                                  : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
 541   if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
 542     return true;
 543   } else {
 544     return false;
 545   }
 546 }
 547 
 548 void os::Bsd::signal_sets_init() {
 549   // Should also have an assertion stating we are still single-threaded.
 550   assert(!signal_sets_initialized, "Already initialized");
 551   // Fill in signals that are necessarily unblocked for all threads in
 552   // the VM. Currently, we unblock the following signals:
 553   // SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden
 554   //                         by -Xrs (=ReduceSignalUsage));
 555   // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all
 556   // other threads. The "ReduceSignalUsage" boolean tells us not to alter
 557   // the dispositions or masks wrt these signals.
 558   // Programs embedding the VM that want to use the above signals for their
 559   // own purposes must, at this time, use the "-Xrs" option to prevent
 560   // interference with shutdown hooks and BREAK_SIGNAL thread dumping.
 561   // (See bug 4345157, and other related bugs).
 562   // In reality, though, unblocking these signals is really a nop, since
 563   // these signals are not blocked by default.
 564   sigemptyset(&unblocked_sigs);
 565   sigaddset(&unblocked_sigs, SIGILL);
 566   sigaddset(&unblocked_sigs, SIGSEGV);
 567   sigaddset(&unblocked_sigs, SIGBUS);
 568   sigaddset(&unblocked_sigs, SIGFPE);
 569   sigaddset(&unblocked_sigs, SR_signum);
 570 
 571   if (!ReduceSignalUsage) {
 572     if (!os::Bsd::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
 573       sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
 574 
 575     }
 576     if (!os::Bsd::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
 577       sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
 578     }
 579     if (!os::Bsd::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
 580       sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
 581     }
 582   }
 583   // Fill in signals that are blocked by all but the VM thread.
 584   sigemptyset(&vm_sigs);
 585   if (!ReduceSignalUsage) {
 586     sigaddset(&vm_sigs, BREAK_SIGNAL);
 587   }
 588   debug_only(signal_sets_initialized = true);
 589 
 590 }
 591 
 592 // These are signals that are unblocked while a thread is running Java.
 593 // (For some reason, they get blocked by default.)
 594 sigset_t* os::Bsd::unblocked_signals() {
 595   assert(signal_sets_initialized, "Not initialized");
 596   return &unblocked_sigs;
 597 }
 598 
 599 // These are the signals that are blocked while a (non-VM) thread is




 516 #undef EXTENSIONS_DIR
 517 }
 518 
 519 ////////////////////////////////////////////////////////////////////////////////
 520 // breakpoint support
 521 
 522 void os::breakpoint() {
 523   BREAKPOINT;
 524 }
 525 
 526 extern "C" void breakpoint() {
 527   // use debugger to set breakpoint here
 528 }
 529 
 530 ////////////////////////////////////////////////////////////////////////////////
 531 // signal support
 532 
 533 debug_only(static bool signal_sets_initialized = false);
 534 static sigset_t unblocked_sigs, vm_sigs;
 535 












 536 void os::Bsd::signal_sets_init() {
 537   // Should also have an assertion stating we are still single-threaded.
 538   assert(!signal_sets_initialized, "Already initialized");
 539   // Fill in signals that are necessarily unblocked for all threads in
 540   // the VM. Currently, we unblock the following signals:
 541   // SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden
 542   //                         by -Xrs (=ReduceSignalUsage));
 543   // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all
 544   // other threads. The "ReduceSignalUsage" boolean tells us not to alter
 545   // the dispositions or masks wrt these signals.
 546   // Programs embedding the VM that want to use the above signals for their
 547   // own purposes must, at this time, use the "-Xrs" option to prevent
 548   // interference with shutdown hooks and BREAK_SIGNAL thread dumping.
 549   // (See bug 4345157, and other related bugs).
 550   // In reality, though, unblocking these signals is really a nop, since
 551   // these signals are not blocked by default.
 552   sigemptyset(&unblocked_sigs);
 553   sigaddset(&unblocked_sigs, SIGILL);
 554   sigaddset(&unblocked_sigs, SIGSEGV);
 555   sigaddset(&unblocked_sigs, SIGBUS);
 556   sigaddset(&unblocked_sigs, SIGFPE);
 557   sigaddset(&unblocked_sigs, SR_signum);
 558 
 559   if (!ReduceSignalUsage) {
 560     if (!os::Posix::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
 561       sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
 562 
 563     }
 564     if (!os::Posix::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
 565       sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
 566     }
 567     if (!os::Posix::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
 568       sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
 569     }
 570   }
 571   // Fill in signals that are blocked by all but the VM thread.
 572   sigemptyset(&vm_sigs);
 573   if (!ReduceSignalUsage) {
 574     sigaddset(&vm_sigs, BREAK_SIGNAL);
 575   }
 576   debug_only(signal_sets_initialized = true);
 577 
 578 }
 579 
 580 // These are signals that are unblocked while a thread is running Java.
 581 // (For some reason, they get blocked by default.)
 582 sigset_t* os::Bsd::unblocked_signals() {
 583   assert(signal_sets_initialized, "Not initialized");
 584   return &unblocked_sigs;
 585 }
 586 
 587 // These are the signals that are blocked while a (non-VM) thread is


< prev index next >