Leopold Toetsch <[EMAIL PROTECTED]> wrote:

> The event handler thread is waiting on a condition, so the only
> possibility seems to be the latter option, that is run another thread
> that does nothing but sigwait(3).

While pressing $send_button I realized, that there is another option and
- of course - we'll have to handle IO events too.

So my local src/events.c does:

1) block all signals before any thread creation
2) install an event handler for SIGINT
3) start the event handler thread
4) start an IO handler thread, which does:
  - unblock SIGINT
  - select in a while loop
  - if select returns -1, check for EINTR and the sig_atomic_t flag
    set by the signal handler

This works fine. Pressing ^C (and ^\ to quit) in sl.pasm now prints
diagnostics for testing:

started
sig_handler SIGINT in pid 2535
select EINTR
int arrived
Quit

$ cat sl.pasm
  print "started\n"
  sleep 1000
  end

The IO thread can then generate a SIGINT_EVENT and pthread_signal the
event thread. And it could wait on various file-handles and on an
internal pipe, which can be used to communicate file-handles to be
waited on to the IO thread.

Comments welcome,

leo

Reply via email to