From: Eshel Yaron Date: Fri, 15 Sep 2023 08:08:04 +0000 (+0200) Subject: Check that top-level thread is alive when signaling it X-Git-Tag: V9.1.15-sweep-0.25.0~5 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=292335770554abdab626694693e7528a88159651;p=sweep.git Check that top-level thread is alive when signaling it * sweeprolog.el (sweeprolog-top-level-signal-current): Delete stale pty "process" when trying to signal a top-level thread that has already exited. --- diff --git a/sweeprolog.el b/sweeprolog.el index ada99c5..b2fbcd5 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -3262,7 +3262,21 @@ GOAL. Otherwise, GOAL is set to a default value specified by sweeprolog-top-level-signal-default-goal))) (unless sweeprolog-top-level-thread-id (sweeprolog-top-level--populate-thread-id)) - (sweeprolog-signal-thread sweeprolog-top-level-thread-id goal)) + (when (and (or (not sweeprolog-top-level-thread-id) + (eq (condition-case error + (sweeprolog-signal-thread sweeprolog-top-level-thread-id goal) + (prolog-exception + (pcase error + (`(prolog-exception + compound "error" + (compound "existence_error" (atom . "thread") ,_) + . + ,_) + 'no-thread)))) + 'no-thread)) + sweeprolog-top-level-use-pty) + (delete-process (get-buffer-process + (current-buffer))))) ;;;###autoload (define-derived-mode sweeprolog-top-level-mode comint-mode "Sweep Top-level"