emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delivering SIGIO when several threads are active?


From: Paul Eggert
Subject: Re: Delivering SIGIO when several threads are active?
Date: Fri, 30 Dec 2016 09:54:01 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

Eli Zaretskii wrote:
When SIGIO is received by some thread, we currently deliver it to the
main thread, see deliver_input_available_signal and
deliver_process_signal.  Is that appropriate when more than one thread
is active?

Such signals have been delivered to the main thread for quite some time, and this has worked well enough; is there something different about the concurrency code that now makes this behavior inappropriate?

The SIGIO handler just sets a global variable, so the
handler itself is okay, I think, but is it okay to interrupt the main
thread with SIGIO at some arbitrary point?  E.g., the main thread
could be in some Xlib or GTK call.

These library functions are all supposed to work even if such handlers interrupt them.

The comments to deliver_process_signal say:

                 POSIX says any thread can receive a signal that is
   associated with a process, process group, or asynchronous event.
   On GNU/Linux that is not true, but for other systems (FreeBSD at
   least) it is.

What does happen on GNU/Linux?  Is there a specific thread on
GNU/Linux which gets signals associated with a process?

On GNU/Linux, process signals get sent to the main thread unless the main thread is blocking them (or if a few less-common situations arise, e.g., the main thread is exiting).

And if so,
does this affect what we should do with SIGIO in this case?

I don't see why it would affect SIGIO handling.

I installed the attached to try to explain this better.

Hmm, I see that the recent changes use mixed terminology. Until now, Emacs has called the initial thread the "main thread", but the recent code sometimes calls it the "primary thread". We shouldn't have two names for the same thing. I'll look into fixing that.

Attachment: 0001-src-sysdep.c-deliver_process_signal-Improve-comment.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]