Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static SCM
- siscm_sigint_listener_thread (void *data)
- {
- char c;
- int rc;
- sigset_t mask;
- /* Check SCM_USE_PTHREAD_THREADS to avoid compilation failures.
- This function will never get called if pthreads aren't available. */
- #if SCM_USE_PTHREAD_THREADS
- /* Block most signals, certainly all async signals. */
- sigfillset (&mask);
- sigdelset (&mask, SIGSEGV);
- sigdelset (&mask, SIGABRT);
- rc = pthread_sigmask (SIG_BLOCK, &mask, NULL);
- #else
- rc = 0;
- #endif
- if (rc != 0)
- {
- fprintf (stderr,
- "GDB/Guile SIGINT thread: Error setting signal mask: %s\n",
- safe_strerror (rc));
- return SCM_BOOL_F;
- }
- for (;;)
- {
- struct signal_pipe_data sigdata;
- scm_without_guile (read_signal_pipe_data, &sigdata);
- if (sigdata.n == 1)
- {
- if (siscm_sigint_mode_enabled)
- {
- scm_system_async_mark_for_thread (siscm_check_and_throw_sigint,
- siscm_main_thread);
- }
- }
- else
- {
- if (sigdata.n < 0)
- {
- gdbscm_printf (scm_current_error_port (),
- "Error reading from SIGINT pipe: %s.\n",
- safe_strerror (sigdata.err));
- }
- break;
- }
- }
- return SCM_BOOL_F;
- }
- Thread is spawned as:
- siscm_listener_thread = scm_spawn_thread (siscm_sigint_listener_thread, NULL,
- siscm_exception_catcher, NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement