init.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /*
  6. Module: initialization and some global vars
  7. Author: Ceriel J.H. Jacobs
  8. Version: $Id$
  9. */
  10. #include <signal.h>
  11. #include <em_abs.h>
  12. #include <m2_traps.h>
  13. static const char signals_list[] = {
  14. #ifdef SIGHUP
  15. SIGHUP,
  16. #endif
  17. #ifdef SIGINT
  18. SIGINT,
  19. #endif
  20. #ifdef SIGQUIT
  21. SIGQUIT,
  22. #endif
  23. #ifdef SIGTRAP
  24. SIGTRAP,
  25. #endif
  26. #ifdef SIGIOT
  27. SIGIOT,
  28. #endif
  29. #ifdef SIGEMT
  30. SIGEMT,
  31. #endif
  32. #ifdef SIGFPE
  33. SIGFPE,
  34. #endif
  35. #ifdef SIGBUS
  36. SIGBUS,
  37. #endif
  38. #ifdef SIGSEGV
  39. SIGSEGV,
  40. #endif
  41. #ifdef SIGPIPE
  42. SIGPIPE,
  43. #endif
  44. #ifdef SIGALRM
  45. SIGALRM,
  46. #endif
  47. #ifdef SIGTERM
  48. SIGTERM,
  49. #endif
  50. -1
  51. };
  52. /* map unix signals onto EM traps */
  53. void init(void)
  54. {
  55. const char* p = signals_list;
  56. do {
  57. int i = *p++;
  58. if (i == -1)
  59. break;
  60. sigtrp(M2_UNIXSIG, i);
  61. } while (1);
  62. sigtrp(EILLINS, SIGILL);
  63. #ifdef SIGSYS
  64. sigtrp(EBADMON, SIGSYS);
  65. #endif
  66. }
  67. #if defined(__em22) || defined(__em24) || defined(__em44)
  68. killbss()
  69. {
  70. }
  71. #else
  72. static int blablabla; /* We cannot use end, because then also
  73. bss allocated for the systemcall lib
  74. would be overwritten. Lets hope that
  75. this helps ...
  76. */
  77. killbss()
  78. {
  79. extern char *bkillbss;
  80. register char *p = (char *) &bkillbss;
  81. while (p < (char *) &blablabla) *p++ = 0x66;
  82. }
  83. #endif
  84. extern int catch();
  85. int (*handler)() = catch;
  86. char **argv = 0, **environ = 0;
  87. int argc = 0;
  88. char *MainLB = 0;