+#if defined(HAVE_SIGNAL) && defined(HAVE_SIGNAL_H)
+static void gras_sigusr_handler(int sig)
+{
+ XBT_INFO("SIGUSR1 received. Display the backtrace");
+ xbt_backtrace_display_current();
+}
+
+static void gras_sigint_handler(int sig)
+{
+ static double lastone = 0;
+ if (lastone == 0 || xbt_os_time() - lastone > 5) {
+ if (gras_if_RL())
+ xbt_backtrace_display_current();
+ else
+ SIMIX_display_process_status();
+ fprintf(stderr,
+ "\nBacktrace displayed because Ctrl-C was pressed. Press again (within 5 sec) to abort the process.\n");
+ lastone = xbt_os_time();
+ } else {
+ exit(1);
+ }
+}
+#endif
+
+XBT_LOG_EXTERNAL_CATEGORY(gras_modules);
+XBT_LOG_EXTERNAL_CATEGORY(gras_msg);
+XBT_LOG_EXTERNAL_CATEGORY(gras_msg_read);
+XBT_LOG_EXTERNAL_CATEGORY(gras_msg_rpc);
+XBT_LOG_EXTERNAL_CATEGORY(gras_timer);
+XBT_LOG_EXTERNAL_CATEGORY(gras_virtu);
+XBT_LOG_EXTERNAL_CATEGORY(gras_virtu_emul);
+XBT_LOG_EXTERNAL_CATEGORY(gras_virtu_process);
+
+/**
+ * @ingroup GRAS_API
+ * \brief Initialize the gras mechanisms.
+ */
+void gras_init(int *argc, char **argv)
+{
+ int first = 0;
+ gras_procdata_t *pd;
+ gras_msg_procdata_t msg_pd;
+
+ xbt_getpid = gras_os_getpid;
+ /* First initialize the XBT */
+ xbt_init(argc, argv);
+
+ XBT_VERB("Initialize GRAS");
+
+ /* module registrations:
+ * - declare process specific data we need (without creating them)
+ */
+ if (gras_running_process == 0) {
+ first = 1;
+ /* Connect our log channels: that must be done manually under windows */
+
+ XBT_LOG_CONNECT(gras_modules, gras);
+
+ XBT_LOG_CONNECT(gras_msg, gras);
+ XBT_LOG_CONNECT(gras_msg_read, gras_msg);
+ XBT_LOG_CONNECT(gras_msg_rpc, gras_msg);
+
+ XBT_LOG_CONNECT(gras_timer, gras);
+
+ XBT_LOG_CONNECT(gras_virtu, gras);
+ XBT_LOG_CONNECT(gras_virtu_emul, gras_virtu);
+ XBT_LOG_CONNECT(gras_virtu_process, gras_virtu);
+
+ if (!getenv("GRAS_NO_WARN_EXPERIMENTAL"))
+ XBT_WARN("GRAS is not well maintained anymore. We consider it to be experimental (and not stable anymore) since SimGrid 3.6. Sorry about it, please consider contributing to improve this situation");
+
+ gras_trp_register();
+ gras_msg_register();