trap_user.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 "signal_user.h"
  20. #include "time_user.h"
  21. #include "task.h"
  22. #include "mode.h"
  23. #include "choose-mode.h"
  24. #include "kern_util.h"
  25. #include "user_util.h"
  26. #include "os.h"
  27. void kill_child_dead(int pid)
  28. {
  29. kill(pid, SIGKILL);
  30. kill(pid, SIGCONT);
  31. do {
  32. int n;
  33. CATCH_EINTR(n = waitpid(pid, NULL, 0));
  34. if (n > 0)
  35. kill(pid, SIGCONT);
  36. else
  37. break;
  38. } while(1);
  39. }
  40. void segv_handler(int sig, union uml_pt_regs *regs)
  41. {
  42. struct faultinfo * fi = UPT_FAULTINFO(regs);
  43. if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){
  44. bad_segv(*fi, UPT_IP(regs));
  45. return;
  46. }
  47. segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs);
  48. }
  49. void usr2_handler(int sig, union uml_pt_regs *regs)
  50. {
  51. CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
  52. }
  53. struct signal_info sig_info[] = {
  54. [ SIGTRAP ] { .handler = relay_signal,
  55. .is_irq = 0 },
  56. [ SIGFPE ] { .handler = relay_signal,
  57. .is_irq = 0 },
  58. [ SIGILL ] { .handler = relay_signal,
  59. .is_irq = 0 },
  60. [ SIGWINCH ] { .handler = winch,
  61. .is_irq = 1 },
  62. [ SIGBUS ] { .handler = bus_handler,
  63. .is_irq = 0 },
  64. [ SIGSEGV] { .handler = segv_handler,
  65. .is_irq = 0 },
  66. [ SIGIO ] { .handler = sigio_handler,
  67. .is_irq = 1 },
  68. [ SIGVTALRM ] { .handler = timer_handler,
  69. .is_irq = 1 },
  70. [ SIGALRM ] { .handler = timer_handler,
  71. .is_irq = 1 },
  72. [ SIGUSR2 ] { .handler = usr2_handler,
  73. .is_irq = 0 },
  74. };
  75. void do_longjmp(void *b, int val)
  76. {
  77. sigjmp_buf *buf = b;
  78. siglongjmp(*buf, val);
  79. }
  80. /*
  81. * Overrides for Emacs so that we follow Linus's tabbing style.
  82. * Emacs will notice this stuff at the end of the file and automatically
  83. * adjust the settings for this buffer only. This must remain at the end
  84. * of the file.
  85. * ---------------------------------------------------------------------------
  86. * Local variables:
  87. * c-file-style: "linux"
  88. * End:
  89. */