unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: 37408@debbugs.gnu.org
Subject: bug#37408: 27.0.50; list-processes can hang
Date: Sun, 15 Sep 2019 14:38:12 +0200	[thread overview]
Message-ID: <878sqpybt7.fsf@gnus.org> (raw)
In-Reply-To: <87zhj54vby.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 15 Sep 2019 14:06:57 +0200")

OK, here's the relevant data in list-processes:

    p = #<process raw.githubusercontent.com<3>>
    type = network
    name = "raw.githubusercontent.com<3>"
    status = "connect"

The problem here is that when a process in the status "connect", it may
be in two distinctly different states: It may still be doing the DNS
lookup (which may fail for some reason or other), and it'll never
progress from that state.  This is usually cleaned up by whatever the
caller is, but if the user has `C-g' somewhere, the process may linger
in that condition.

And if it's in that state, then the rest of Fprocess_contact can't be
done, because the data isn't present.

But there's another "connect" state -- after the DNS has been completed,
and we're doing a TCP connect.  In that case, the rest of the function
is fine to do, because we've filled in the peer etc.

`list-processes' could avoid calling Fprocess_contact if the status is
"connect", but that would lose info on processes in the second
sub-state.

So I don't know...  Anybody got an idea?  Introducing a new state
("pre-connect") would probably break a lot of stuff; adding a timeout
parameter and then return nil if it's exceeded would be possible; making
list-processes not display the details for all "connect" processes is
possible.  It would look like this:

raw.githubus... --      connect  *http raw.githubuserc... --           Main         (connecting)

Patch for reference.

diff --git a/lisp/simple.el b/lisp/simple.el
index 358b6a4f20..5812111109 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4107,30 +4107,32 @@ list-processes--refresh
 		    (t "--")))
 		  (cmd
 		   (if (memq type '(network serial))
-		       (let ((contact (process-contact p t)))
-			 (if (eq type 'network)
-			     (format "(%s %s)"
-				     (if (plist-get contact :type)
-					 "datagram"
-				       "network")
-				     (if (plist-get contact :server)
-					 (format
-                                          "server on %s"
-					  (if (plist-get contact :host)
-                                              (format "%s:%s"
-						      (plist-get contact :host)
-                                                      (plist-get
-                                                       contact :service))
-					    (plist-get contact :local)))
-				       (format "connection to %s:%s"
-					       (plist-get contact :host)
-					       (plist-get contact :service))))
-			   (format "(serial port %s%s)"
-				   (or (plist-get contact :port) "?")
-				   (let ((speed (plist-get contact :speed)))
-				     (if speed
-					 (format " at %s b/s" speed)
-				       "")))))
+                       (if (equal status "connect")
+                           "(connecting)"
+		         (let ((contact (process-contact p t)))
+			   (if (eq type 'network)
+			       (format "(%s %s)"
+				       (if (plist-get contact :type)
+					   "datagram"
+				         "network")
+				       (if (plist-get contact :server)
+					   (format
+                                            "server on %s"
+					    (if (plist-get contact :host)
+                                                (format "%s:%s"
+						        (plist-get contact :host)
+                                                        (plist-get
+                                                         contact :service))
+					      (plist-get contact :local)))
+				         (format "connection to %s:%s"
+					         (plist-get contact :host)
+					         (plist-get contact :service))))
+			     (format "(serial port %s%s)"
+				     (or (plist-get contact :port) "?")
+				     (let ((speed (plist-get contact :speed)))
+				       (if speed
+					   (format " at %s b/s" speed)
+				         ""))))))
 		     (mapconcat 'identity (process-command p) " "))))
 	     (push (list p (vector name pid status buf-label tty thread cmd))
 		   tabulated-list-entries)))))


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no






      parent reply	other threads:[~2019-09-15 12:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15 12:06 bug#37408: 27.0.50; list-processes can hang Lars Ingebrigtsen
2019-09-15 12:25 ` Lars Ingebrigtsen
2019-09-15 14:54   ` Eli Zaretskii
2019-09-16 13:20     ` Lars Ingebrigtsen
2019-09-20 18:20       ` Lars Ingebrigtsen
2019-09-15 12:38 ` Lars Ingebrigtsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sqpybt7.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=37408@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).