#include "arch.h"
-#include "threads/thread.h"
+#if defined(ENABLE_GC_BOEHM)
+# include "mm/memory.h"
+#endif
-#include "vm/exceptions.h"
-#include "vm/signallocal.h"
-#include "vm/vm.h"
+#include "threads/thread.hpp"
+#include "threads/threadlist.hpp"
-#include "vmcore/options.h"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/signallocal.h"
+#include "vm/vm.hpp"
#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
+# include "vm/statistics.h"
#endif
if (sigemptyset(&mask) != 0)
vm_abort_errno("signal_init: sigemptyset failed");
-#if !defined(WITH_CLASSPATH_SUN)
+#if !defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
/* Let OpenJDK handle SIGINT itself. */
if (sigaddset(&mask, SIGINT) != 0)
SA_NODEFER | SA_SIGINFO);
# endif
-# if defined(__ARM__) || defined(__I386__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
+# if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
/* XXX use better defines for that (in arch.h) */
/* SIGILL handler */
#if defined(ENABLE_THREADS)
/* SIGHUP handler for threads_thread_interrupt */
- signal_register_signal(SIGHUP, (functionptr) signal_handler_sighup, 0);
+ signal_register_signal(Signal_INTERRUPT_SYSTEM_CALL, (functionptr) signal_handler_sighup, 0);
#endif
#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
threadobject *t;
sigset_t mask;
int sig;
+ int result;
t = THREADOBJECT;
if (sigemptyset(&mask) != 0)
vm_abort_errno("signal_thread: sigemptyset failed");
-#if !defined(WITH_CLASSPATH_SUN)
+#if !defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
/* Let OpenJDK handle SIGINT itself. */
if (sigaddset(&mask, SIGINT) != 0)
thread_set_state_waiting(t);
#endif
- /* XXX We don't check for an error here, although the man-page
- states sigwait does not return an error (which is wrong!),
- but it seems to make problems with Boehm-GC. We should
- revisit this code with our new exact-GC. */
+ // sigwait can return EINTR (unlike what the Linux man-page
+ // says).
+ do {
+ result = sigwait(&mask, &sig);
+ } while (result == EINTR);
-/* if (sigwait(&mask, &sig) != 0) */
-/* vm_abort_errno("signal_thread: sigwait failed"); */
- (void) sigwait(&mask, &sig);
+ if (result != 0)
+ vm_abort_errnum(result, "signal_thread: sigwait failed");
#if defined(ENABLE_THREADS)
thread_set_state_runnable(t);
case SIGINT:
/* exit the vm properly */
- vm_exit(0);
+ vm_exit(1);
break;
case SIGQUIT:
/* print a thread dump */
#if defined(ENABLE_THREADS)
- threads_dump();
+ ThreadList_dump_threads();
#endif
#if defined(ENABLE_STATISTICS)
statistics_print_memory_usage();
#endif
break;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+ default: {
+ // For OpenJDK we dispatch all unknown signals to Java.
+ methodinfo* m = class_resolvemethod(class_sun_misc_Signal, utf_dispatch, utf_int__void);
+ (void) vm_call_method(m, NULL, sig);
+
+ if (exceptions_get_exception()) {
+ log_println("signal_thread_handler: Java signal handler throw an exception while dispatching signal %d:", sig);
+ exceptions_print_stacktrace();
+ vm_abort("signal_thread_handler: Aborting...");
+ }
+ break;
+ }
+#else
+ default:
+ vm_abort("signal_thread_handler: Unknown signal %d", sig);
+#endif
}
}