diff options
| -rw-r--r-- | src/thread.c | 3 | ||||
| -rw-r--r-- | test/automated/threads.el | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c index 01d2fd0d6eb..551f3de10e4 100644 --- a/src/thread.c +++ b/src/thread.c | |||
| @@ -852,6 +852,9 @@ It is an error for a thread to try to join itself. */) | |||
| 852 | CHECK_THREAD (thread); | 852 | CHECK_THREAD (thread); |
| 853 | tstate = XTHREAD (thread); | 853 | tstate = XTHREAD (thread); |
| 854 | 854 | ||
| 855 | if (tstate == current_thread) | ||
| 856 | error ("cannot join current thread"); | ||
| 857 | |||
| 855 | if (tstate->m_specpdl != NULL) | 858 | if (tstate->m_specpdl != NULL) |
| 856 | flush_stack_call_func (thread_join_callback, tstate); | 859 | flush_stack_call_func (thread_join_callback, tstate); |
| 857 | 860 | ||
diff --git a/test/automated/threads.el b/test/automated/threads.el index b1c2af59600..db6aa41d63a 100644 --- a/test/automated/threads.el +++ b/test/automated/threads.el | |||
| @@ -70,6 +70,10 @@ | |||
| 70 | (and threads-test-global | 70 | (and threads-test-global |
| 71 | (not (thread-alive-p thread))))))) | 71 | (not (thread-alive-p thread))))))) |
| 72 | 72 | ||
| 73 | (ert-deftest threads-join-self () | ||
| 74 | "cannot thread-join the current thread" | ||
| 75 | (should-error (thread-join (current-thread)))) | ||
| 76 | |||
| 73 | (defvar threads-test-binding nil) | 77 | (defvar threads-test-binding nil) |
| 74 | 78 | ||
| 75 | (defun threads-test-thread2 () | 79 | (defun threads-test-thread2 () |