From: Reuben Thomas <rrt@sc3d.org>
Date: Sun, 27 Jun 2021 21:07:06 +0000 (+0100)
Subject: * lisp/textmodes/ispell.el: Check process is live before interacting.
X-Git-Tag: emacs-28.0.90~2013
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=881e75873dfb15077413d96c6606bbf042ab0a93;p=emacs.git

* lisp/textmodes/ispell.el: Check process is live before interacting.

Check that `ispell-process' is live before trying to read from or
write to it. This avoids a hang if the process has died.
---

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 4dbc7640bcf..84d7208151a 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1765,10 +1765,12 @@ You can set this variable in hooks in your init file -- eg:
 If asynchronous subprocesses are not supported, call function `ispell-filter'
 and pass it the output of the last Ispell invocation."
   (if ispell-async-processp
-      (let ((timeout (if timeout-msecs
-			 (+ (or timeout-secs 0) (/ timeout-msecs 1000.0))
-		       timeout-secs)))
-	(accept-process-output ispell-process timeout))
+      (if (process-live-p ispell-process)
+       (let ((timeout (if timeout-msecs
+			  (+ (or timeout-secs 0) (/ timeout-msecs 1000.0))
+		        timeout-secs)))
+	 (accept-process-output ispell-process timeout))
+       (error "No Ispell process to read output from!"))
     (if (null ispell-process)
 	(error "No Ispell process to read output from!")
       (let ((buf ispell-output-buffer)
@@ -1793,7 +1795,8 @@ Only works for Aspell and Enchant."
 (defun ispell-send-string (string)
   "Send the string STRING to the Ispell process."
   (if ispell-async-processp
-      (process-send-string ispell-process string)
+      (if (process-live-p ispell-process)
+       (process-send-string ispell-process string))
     ;; Asynchronous subprocesses aren't supported on this losing system.
     ;; We keep all the directives passed to Ispell during the entire
     ;; session in a buffer, and pass them anew each time we invoke