Subject: Re: bug#42160: Issue with Man-kill and background process.

From: Eli Zaretskii <[email-masked]>
Date: Fri, 03 Jul 2020 11:02:08 +0300

> Date: Thu, 2 Jul 2020 04:23:09 +0200
> From: Ergus via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> When using man with big manuals (like gcc). There is an error when
> trying to quit with k just after opening the manual.
> This seems to be related with the formating process that is running in
> the background.
> 
> To reproduce the issue:
> 
> emacs -Q
> M-x toggle-debug-on-error RET
> M-x man RET
> gcc RET
> k
> 
> And I get this error message:
> 
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   Man-bgproc-filter(#<process man> "nt, there is no need to use address spaces like \"_...")

Thanks.  Does the patch below fix this?

diff --git a/lisp/man.el b/lisp/man.el
index 5278a1a..bc8fd45 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1392,7 +1392,7 @@ Man-bgproc-filter
 command is run.  Second argument STRING is the entire string of output."
   (save-excursion
     (let ((Man-buffer (process-buffer process)))
-      (if (null (buffer-name Man-buffer)) ;; deleted buffer
+      (if (not (buffer-live-p Man-buffer)) ;; deleted buffer
 	  (set-process-buffer process nil)
 
 	(with-current-buffer Man-buffer
@@ -1426,7 +1426,7 @@ Man-bgproc-sentinel
 	(delete-buff nil)
 	message)
 
-    (if (null (buffer-name Man-buffer)) ;; deleted buffer
+    (if (not (buffer-live-p Man-buffer)) ;; deleted buffer
 	(or (stringp process)
 	    (set-process-buffer process nil))