From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#32502: 27.0.50; Tramp; C-g during asynchronous remote find-file kills Emacs Date: Thu, 30 Aug 2018 18:48:19 +0200 Message-ID: <87h8jb7qcs.fsf@gmx.de> References: <87mutep8ll.fsf@runbox.com> <83o9dub5nx.fsf@gnu.org> <83muteb4nb.fsf@gnu.org> <87o9dqbtv5.fsf@gmx.de> <87efemp0yz.fsf@runbox.com> <87pny1xiv5.fsf@gmx.de> <83in3t2lcl.fsf@gnu.org> <87lg8pxgs6.fsf@gmx.de> <83h8jd2jh6.fsf@gnu.org> <87d0u1xfek.fsf@gmx.de> <878t4oylcj.fsf@gmx.de> <874lfcyjpn.fsf@gmx.de> <834lfc37ji.fsf@gnu.org> <87zhx4wcsp.fsf@gmx.de> <83va7s0z7g.fsf@gnu.org> <87o9dkrncl.fsf@gmx.de> <83mut40xpp.fsf@gnu.org> <87h8jcvtt1.fsf@gmx.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1535647681 10223 195.159.176.226 (30 Aug 2018 16:48:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 30 Aug 2018 16:48:01 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: gazally@runbox.com, 32502@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 30 18:47:57 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fvQ6r-0002UA-8k for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Aug 2018 18:47:53 +0200 Original-Received: from localhost ([::1]:49986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvQ8x-00063e-KQ for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Aug 2018 12:50:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvQ87-0005Z5-Qi for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2018 12:49:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvQ82-0003JL-6g for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2018 12:49:11 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34315) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fvQ7y-0003EW-DF for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2018 12:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fvQ7y-0004hZ-5G for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2018 12:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Aug 2018 16:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32502 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 32502-submit@debbugs.gnu.org id=B32502.153564771218034 (code B ref 32502); Thu, 30 Aug 2018 16:49:02 +0000 Original-Received: (at 32502) by debbugs.gnu.org; 30 Aug 2018 16:48:32 +0000 Original-Received: from localhost ([127.0.0.1]:39333 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fvQ7T-0004go-J7 for submit@debbugs.gnu.org; Thu, 30 Aug 2018 12:48:31 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:41185) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fvQ7R-0004gW-Qa for 32502@debbugs.gnu.org; Thu, 30 Aug 2018 12:48:30 -0400 Original-Received: from detlef.gmx.de ([212.91.238.173]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MEo4s-1g6yZr1hVK-00G4jj; Thu, 30 Aug 2018 18:48:21 +0200 In-Reply-To: <87h8jcvtt1.fsf@gmx.de> (Michael Albinus's message of "Thu, 30 Aug 2018 15:59:54 +0200") X-Provags-ID: V03:K1:HsfuY8R/oO886uE9+oc6bBcaDAhsq2gC8fwRaeAyuLuD9w2Otk/ 5HKt9ktRsMr9w+gVJFQ/AMKdkDxlHwYJgGkBf8mgUullXU7+dLFvBnrXFJyaCvmp0oB21kr gOMnCsUHzdUGfr0OwGqkeSPEODqM66R+XON7zwfpWNDHGER3JNphwOtuw4ktnlw8nC2xqT0 uokLboqMPM43QEVvGQB5Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:TZTwOkrQsbY=:zT9RXTH/i7298S54BhPVLC LZJCkFUhg+cf4fabvuOeLsJ8YKE3dGCCRpogxLqmRHKcMnYHTpsdG3Hd29nMj7QaA0ipljmKQ 76VJI+BsjzwzmPEuU90g+zJ6HNnmt5xm6G6twfTi86iqvTxeB7VWqWhd5TZJThLKhCPLbHs1n WgovMFi8VvRkgi5s1SNAXJAVap8J9du55GP1Ya9rboyRqn3PlbqSa+OK6PQEvIPWZ5xkLlPvK jmYedfxrVCykULHamlfBAvyuTKCoyOXv8MjjICt9cVPjdQBrovp7GxgUai6ex0kXYMTR6CfEF s4kstPh2Bq9d1kr7OQ+YQodRk+vdApmDmI6/IaHNpXpb62lhUkQmmAHOzkqgwM3j13twNT8L8 nkuZYzFf/6krcYYlGhzLvdXkdys4XI1neFaqLCgMDPJhGJ8YHe/HxheQ7I7t0AMspn45+RA8g DANDeRMI9KcPIUktopLSmgN6F9qt/KCpep67EYh4oZ0O2Lpn6Gq6nNQzot/MT7M37isWqmf3M A5UKNlAAh4x3QTHFfWmLX9il73GnoR3dER3HzhKKgNaRtKg7/tYUF2ctpsu2uqGt+JzWWCSOV +9gbhF9jqZ25EBKR+FEaxA8tpXCSVb5kkCf3wEHkBtx1b4O5/uKZQ8oHwbP6zd/1fyUiqLS9S BoIn+ifXnnxhPnUkDfabYlcVoQAW9XVzSHJWSBxjwHQBdsMuat9ew7xRGKfluwNu60yseqO0n AppVq27XYj/qwkkt2QtjLVLErU7Jptfn9WCxAaThon8ZKqTJqJCYmBj/tn8= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149883 Archived-At: --=-=-= Content-Type: text/plain Michael Albinus writes: >>> I'm just changing thread-signal such a way that it ignores silently >>> signals sent to the main thread. Shall I implement this event injection >>> instead? >> >> I don't know. I guess it depends on how important is it to show the >> errors nicely. You could leave signals for now and use the events >> idea later as an enhancement. > > I will see how easy it is. I have experience with dbus-event and > file-notify-event; it shouldn't too hard for me to implement thread-event. > >>> And what shall be done with this event in the main thread? Just writing >>> an error message, or some kind of handling? >> >> Yes, displaying a message would be a good starting point, I think. > > Since special events have their own handler, it will be simple to change > later. Will start with echoing the error message. Appended is a first implementation. Comments? Best regards, Michael. --=-=-= Content-Type: text/plain Content-Disposition: attachment diff --git a/doc/lispref/threads.texi b/doc/lispref/threads.texi index 58a3a918ef..9830198411 100644 --- a/doc/lispref/threads.texi +++ b/doc/lispref/threads.texi @@ -88,14 +88,8 @@ Basic Thread Functions @code{condition-wait}, or @code{thread-join}; @code{thread-signal} will unblock it. -Since signal handlers in Emacs are located in the main thread, a -signal must be propagated there in order to become visible. The -second @code{signal} call let the thread die: - -@example -(thread-signal main-thread 'error data) -(signal 'error data) -@end example +If @var{thread} is the main thread, the signal is not propagated +there. Instead, it is shown as message in the main thread. @end defun @defun thread-yield diff --git a/src/keyboard.c b/src/keyboard.c index 7fafb41fcc..008d3b9d7c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2827,6 +2827,9 @@ read_char (int commandflag, Lisp_Object map, #endif #ifdef USE_FILE_NOTIFY || EQ (XCAR (c), Qfile_notify) +#endif +#ifdef THREADS_ENABLED + || EQ (XCAR (c), Qthread_event) #endif || EQ (XCAR (c), Qconfig_changed_event)) && !end_time) @@ -3739,7 +3742,7 @@ kbd_buffer_get_event (KBOARD **kbp, } #endif /* subprocesses */ -#if !defined HAVE_DBUS && !defined USE_FILE_NOTIFY +#if !defined HAVE_DBUS && !defined USE_FILE_NOTIFY && !defined THREADS_ENABLED if (noninteractive /* In case we are running as a daemon, only do this before detaching from the terminal. */ @@ -3750,7 +3753,7 @@ kbd_buffer_get_event (KBOARD **kbp, *kbp = current_kboard; return obj; } -#endif /* !defined HAVE_DBUS && !defined USE_FILE_NOTIFY */ +#endif /* !defined HAVE_DBUS && !defined USE_FILE_NOTIFY && !defined THREADS_ENABLED */ /* Wait until there is input available. */ for (;;) @@ -3900,6 +3903,9 @@ kbd_buffer_get_event (KBOARD **kbp, #ifdef HAVE_DBUS case DBUS_EVENT: #endif +#ifdef THREADS_ENABLED + case THREAD_EVENT: +#endif #ifdef HAVE_XWIDGETS case XWIDGET_EVENT: #endif @@ -5983,6 +5989,13 @@ make_lispy_event (struct input_event *event) } #endif /* HAVE_DBUS */ +#ifdef THREADS_ENABLED + case THREAD_EVENT: + { + return Fcons (Qthread_event, event->arg); + } +#endif /* THREADS_ENABLED */ + #ifdef HAVE_XWIDGETS case XWIDGET_EVENT: { @@ -11078,6 +11091,10 @@ syms_of_keyboard (void) DEFSYM (Qdbus_event, "dbus-event"); #endif +#ifdef THREADS_ENABLED + DEFSYM (Qthread_event, "thread-event"); +#endif + #ifdef HAVE_XWIDGETS DEFSYM (Qxwidget_event, "xwidget-event"); #endif @@ -11929,6 +11946,12 @@ keys_of_keyboard (void) "dbus-handle-event"); #endif +#ifdef THREADS_ENABLED + /* Define a special event which is raised for thread signals. */ + initial_define_lispy_key (Vspecial_event_map, "thread-event", + "thread-handle-event"); +#endif + #ifdef USE_FILE_NOTIFY /* Define a special event which is raised for notification callback functions. */ diff --git a/src/termhooks.h b/src/termhooks.h index 160bd2f480..8b5f648b43 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -222,6 +222,10 @@ enum event_kind , DBUS_EVENT #endif +#ifdef THREADS_ENABLED + , THREAD_EVENT +#endif + , CONFIG_CHANGED_EVENT #ifdef HAVE_NTGUI diff --git a/src/thread.c b/src/thread.c index 1c73d93865..0234f65e02 100644 --- a/src/thread.c +++ b/src/thread.c @@ -25,6 +25,7 @@ along with GNU Emacs. If not, see . */ #include "process.h" #include "coding.h" #include "syssignal.h" +#include "keyboard.h" static struct thread_state main_thread; @@ -34,7 +35,6 @@ static struct thread_state *all_threads = &main_thread; static sys_mutex_t global_lock; -extern int poll_suppress_count; extern volatile int interrupt_input_blocked; @@ -863,7 +863,8 @@ DEFUN ("thread-signal", Fthread_signal, Sthread_signal, 3, 3, 0, This acts like `signal', but arranges for the signal to be raised in THREAD. If THREAD is the current thread, acts just like `signal'. This will interrupt a blocked call to `mutex-lock', `condition-wait', -or `thread-join' in the target thread. */) +or `thread-join' in the target thread. +Signals to the main thread are ignored quietly. */) (Lisp_Object thread, Lisp_Object error_symbol, Lisp_Object data) { struct thread_state *tstate; @@ -874,13 +875,29 @@ or `thread-join' in the target thread. */) if (tstate == current_thread) Fsignal (error_symbol, data); - /* What to do if thread is already signaled? */ - /* What if error_symbol is Qnil? */ - tstate->error_symbol = error_symbol; - tstate->error_data = data; + if (main_thread_p (tstate)) + { + /* Construct an event. */ + struct input_event event; + EVENT_INIT (event); + event.kind = THREAD_EVENT; + event.frame_or_window = Qnil; + event.arg = list3 (Fcurrent_thread (), error_symbol, data); + + /* Store it into the input event queue. */ + kbd_buffer_store_event (&event); + } + + else + { + /* What to do if thread is already signaled? */ + /* What if error_symbol is Qnil? */ + tstate->error_symbol = error_symbol; + tstate->error_data = data; - if (tstate->wait_condvar) - flush_stack_call_func (thread_signal_callback, tstate); + if (tstate->wait_condvar) + flush_stack_call_func (thread_signal_callback, tstate); + } return Qnil; } --=-=-=--