- return scm_primitive_eval_x (scm_list_3 (scm_sym_lambda, SCM_EOL,
- scm_list_2 (proc, arg)));
+ int sig;
+#if HAVE_PTHREAD_SIGMASK /* not on mingw, see notes above */
+ sigset_t all_sigs;
+ sigfillset (&all_sigs);
+ scm_i_pthread_sigmask (SIG_SETMASK, &all_sigs, NULL);
+#endif
+
+ while (1)
+ {
+ struct signal_pipe_data sigdata;
+
+ scm_without_guile (read_signal_pipe_data, &sigdata);
+
+ sig = sigdata.sigbyte;
+ if (sigdata.n == 1 && sig >= 0 && sig < NSIG)
+ {
+ SCM h, t;
+
+ h = SCM_SIMPLE_VECTOR_REF (signal_handler_asyncs, sig);
+ t = SCM_SIMPLE_VECTOR_REF (signal_handler_threads, sig);
+ if (scm_is_true (h))
+ scm_system_async_mark_for_thread (h, t);
+ }
+ else if (sigdata.n == 0)
+ break; /* the signal pipe was closed. */
+ else if (sigdata.n < 0 && sigdata.err != EINTR)
+ perror ("error in signal delivery thread");
+ }
+
+ return SCM_UNSPECIFIED; /* not reached unless all other threads exited */