trap_user.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include <stdlib.h>
  6. #include <errno.h>
  7. #include <setjmp.h>
  8. #include <signal.h>
  9. #include <sys/time.h>
  10. #include <sys/wait.h>
  11. #include <asm/page.h>
  12. #include <asm/unistd.h>
  13. #include <asm/ptrace.h>
  14. #include "init.h"
  15. #include "sysdep/ptrace.h"
  16. #include "sigcontext.h"
  17. #include "sysdep/sigcontext.h"
  18. #include "irq_user.h"
  19. #include "time_user.h"
  20. #include "task.h"
  21. #include "mode.h"
  22. #include "choose-mode.h"
  23. #include "kern_util.h"
  24. #include "user_util.h"
  25. #include "os.h"
  26. void kill_child_dead(int pid)
  27. {
  28. kill(pid, SIGKILL);
  29. kill(pid, SIGCONT);
  30. do {
  31. int n;
  32. CATCH_EINTR(n = waitpid(pid, NULL, 0));
  33. if (n > 0)
  34. kill(pid, SIGCONT);
  35. else
  36. break;
  37. } while(1);
  38. }
  39. void segv_handler(int sig, union uml_pt_regs *regs)
  40. {
  41. struct faultinfo * fi = UPT_FAULTINFO(regs);
  42. if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){
  43. bad_segv(*fi, UPT_IP(regs));
  44. return;
  45. }
  46. segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs);
  47. }
  48. void usr2_handler(int sig, union uml_pt_regs *regs)
  49. {
  50. CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
  51. }
  52. struct signal_info sig_info[] = {
  53. [ SIGTRAP ] { .handler = relay_signal,
  54. .is_irq = 0 },
  55. [ SIGFPE ] { .handler = relay_signal,
  56. .is_irq = 0 },
  57. [ SIGILL ] { .handler = relay_signal,
  58. .is_irq = 0 },
  59. [ SIGWINCH ] { .handler = winch,
  60. .is_irq = 1 },
  61. [ SIGBUS ] { .handler = bus_handler,
  62. .is_irq = 0 },
  63. [ SIGSEGV] { .handler = segv_handler,
  64. .is_irq = 0 },
  65. [ SIGIO ] { .handler = sigio_handler,
  66. .is_irq = 1 },
  67. [ SIGVTALRM ] { .handler = timer_handler,
  68. .is_irq = 1 },
  69. [ SIGALRM ] { .handler = timer_handler,
  70. .is_irq = 1 },
  71. [ SIGUSR2 ] { .handler = usr2_handler,
  72. .is_irq = 0 },
  73. };
  74. void do_longjmp(void *b, int val)
  75. {
  76. sigjmp_buf *buf = b;
  77. siglongjmp(*buf, val);
  78. }
  79. /*
  80. * Overrides for Emacs so that we follow Linus's tabbing style.
  81. * Emacs will notice this stuff at the end of the file and automatically
  82. * adjust the settings for this buffer only. This must remain at the end
  83. * of the file.
  84. * ---------------------------------------------------------------------------
  85. * Local variables:
  86. * c-file-style: "linux"
  87. * End:
  88. */