Advertisement
Guest User

Untitled

a guest
Feb 16th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. static SCM
  2. siscm_sigint_listener_thread (void *data)
  3. {
  4. char c;
  5. int rc;
  6. sigset_t mask;
  7.  
  8. /* Check SCM_USE_PTHREAD_THREADS to avoid compilation failures.
  9. This function will never get called if pthreads aren't available. */
  10. #if SCM_USE_PTHREAD_THREADS
  11. /* Block most signals, certainly all async signals. */
  12. sigfillset (&mask);
  13. sigdelset (&mask, SIGSEGV);
  14. sigdelset (&mask, SIGABRT);
  15. rc = pthread_sigmask (SIG_BLOCK, &mask, NULL);
  16. #else
  17. rc = 0;
  18. #endif
  19. if (rc != 0)
  20. {
  21. fprintf (stderr,
  22. "GDB/Guile SIGINT thread: Error setting signal mask: %s\n",
  23. safe_strerror (rc));
  24. return SCM_BOOL_F;
  25. }
  26.  
  27. for (;;)
  28. {
  29. struct signal_pipe_data sigdata;
  30.  
  31. scm_without_guile (read_signal_pipe_data, &sigdata);
  32.  
  33. if (sigdata.n == 1)
  34. {
  35. if (siscm_sigint_mode_enabled)
  36. {
  37. scm_system_async_mark_for_thread (siscm_check_and_throw_sigint,
  38. siscm_main_thread);
  39. }
  40. }
  41. else
  42. {
  43. if (sigdata.n < 0)
  44. {
  45. gdbscm_printf (scm_current_error_port (),
  46. "Error reading from SIGINT pipe: %s.\n",
  47. safe_strerror (sigdata.err));
  48. }
  49. break;
  50. }
  51. }
  52.  
  53. return SCM_BOOL_F;
  54. }
  55.  
  56. Thread is spawned as:
  57.  
  58. siscm_listener_thread = scm_spawn_thread (siscm_sigint_listener_thread, NULL,
  59. siscm_exception_catcher, NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement