aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-09-20 20:19:28 +0200
committerLars Ingebrigtsen2019-09-20 20:19:28 +0200
commitb8e9baac9ada62c2ea7437579df4be9d4f437fda (patch)
tree6b91ed5b5a4f48bb47e7e12e7dc42d7d2e07fb59 /src/process.c
parent385bb140de767ff59b026f5540e0e8bfae53fb55 (diff)
downloademacs-b8e9baac9ada62c2ea7437579df4be9d4f437fda.tar.gz
emacs-b8e9baac9ada62c2ea7437579df4be9d4f437fda.zip
Allow `process-contact' not to block
* doc/lispref/processes.texi (Process Information): Document it. * lisp/simple.el (list-processes--refresh): Don't wait for contact information for non-setup processes. * src/process.c (Fprocess_contact): Take an optional parameter to avoid blocking (bug#37408).
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/process.c b/src/process.c
index 372277a953d..a95192d8fba 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1456,7 +1456,7 @@ DEFUN ("process-query-on-exit-flag",
1456} 1456}
1457 1457
1458DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, 1458DEFUN ("process-contact", Fprocess_contact, Sprocess_contact,
1459 1, 2, 0, 1459 1, 3, 0,
1460 doc: /* Return the contact info of PROCESS; t for a real child. 1460 doc: /* Return the contact info of PROCESS; t for a real child.
1461For a network or serial or pipe connection, the value depends on the 1461For a network or serial or pipe connection, the value depends on the
1462optional KEY arg. If KEY is nil, value is a cons cell of the form 1462optional KEY arg. If KEY is nil, value is a cons cell of the form
@@ -1465,9 +1465,12 @@ connection; it is t for a pipe connection. If KEY is t, the complete
1465contact information for the connection is returned, else the specific 1465contact information for the connection is returned, else the specific
1466value for the keyword KEY is returned. See `make-network-process', 1466value for the keyword KEY is returned. See `make-network-process',
1467`make-serial-process', or `make-pipe-process' for the list of keywords. 1467`make-serial-process', or `make-pipe-process' for the list of keywords.
1468
1468If PROCESS is a non-blocking network process that hasn't been fully 1469If PROCESS is a non-blocking network process that hasn't been fully
1469set up yet, this function will block until socket setup has completed. */) 1470set up yet, this function will block until socket setup has completed.
1470 (Lisp_Object process, Lisp_Object key) 1471If the optional NO-BLOCK parameter is specified, return nil instead of
1472waiting for the process to be fully set up.*/)
1473 (Lisp_Object process, Lisp_Object key, Lisp_Object no_block)
1471{ 1474{
1472 Lisp_Object contact; 1475 Lisp_Object contact;
1473 1476
@@ -1476,8 +1479,15 @@ set up yet, this function will block until socket setup has completed. */)
1476 1479
1477#ifdef DATAGRAM_SOCKETS 1480#ifdef DATAGRAM_SOCKETS
1478 1481
1479 if (NETCONN_P (process)) 1482 if (NETCONN_P (process) && XPROCESS (process)->infd < 0)
1480 wait_for_socket_fds (process, "process-contact"); 1483 {
1484 /* Usually wait for the network process to finish being set
1485 * up. */
1486 if (!NILP (no_block))
1487 return Qnil;
1488
1489 wait_for_socket_fds (process, "process-contact");
1490 }
1481 1491
1482 if (DATAGRAM_CONN_P (process) 1492 if (DATAGRAM_CONN_P (process)
1483 && (EQ (key, Qt) || EQ (key, QCremote))) 1493 && (EQ (key, Qt) || EQ (key, QCremote)))