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).
This commit is contained in:
parent
385bb140de
commit
b8e9baac9a
4 changed files with 26 additions and 7 deletions
|
@ -1042,7 +1042,7 @@ this is either @code{nil}, which means the process is running or
|
|||
@end smallexample
|
||||
@end defun
|
||||
|
||||
@defun process-contact process &optional key
|
||||
@defun process-contact process &optional key no-block
|
||||
This function returns information about how a network, a serial, or a
|
||||
pipe connection was set up. When @var{key} is @code{nil}, it returns
|
||||
@code{(@var{hostname} @var{service})} for a network connection,
|
||||
|
@ -1086,6 +1086,11 @@ connection, see @code{make-pipe-process} for the list of keys.
|
|||
|
||||
If @var{key} is a keyword, the function returns the value corresponding
|
||||
to that keyword.
|
||||
|
||||
If @var{process} is a non-blocking network stream that hasn't been
|
||||
fully set up yet, then this function will block until that has
|
||||
happened. If given the optional @var{no-block} parameter, this
|
||||
function will return @code{nil} instead of blocking.
|
||||
@end defun
|
||||
|
||||
@defun process-id process
|
||||
|
|
4
etc/NEWS
4
etc/NEWS
|
@ -2130,6 +2130,10 @@ valid event type.
|
|||
|
||||
* Lisp Changes in Emacs 27.1
|
||||
|
||||
+++
|
||||
** 'process-contact' now takes an optional NO-BLOCK parameter to allow
|
||||
not waiting for a process to be set up.
|
||||
|
||||
+++
|
||||
** The new 'quit-window-hook' is now run first when executing the
|
||||
'quit-window' command.
|
||||
|
|
|
@ -4107,7 +4107,7 @@ Also, delete any process that is exited or signaled."
|
|||
(t "--")))
|
||||
(cmd
|
||||
(if (memq type '(network serial))
|
||||
(let ((contact (process-contact p t)))
|
||||
(let ((contact (process-contact p t t)))
|
||||
(if (eq type 'network)
|
||||
(format "(%s %s)"
|
||||
(if (plist-get contact :type)
|
||||
|
|
|
@ -1456,7 +1456,7 @@ DEFUN ("process-query-on-exit-flag",
|
|||
}
|
||||
|
||||
DEFUN ("process-contact", Fprocess_contact, Sprocess_contact,
|
||||
1, 2, 0,
|
||||
1, 3, 0,
|
||||
doc: /* Return the contact info of PROCESS; t for a real child.
|
||||
For a network or serial or pipe connection, the value depends on the
|
||||
optional 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
|
|||
contact information for the connection is returned, else the specific
|
||||
value for the keyword KEY is returned. See `make-network-process',
|
||||
`make-serial-process', or `make-pipe-process' for the list of keywords.
|
||||
|
||||
If PROCESS is a non-blocking network process that hasn't been fully
|
||||
set up yet, this function will block until socket setup has completed. */)
|
||||
(Lisp_Object process, Lisp_Object key)
|
||||
set up yet, this function will block until socket setup has completed.
|
||||
If the optional NO-BLOCK parameter is specified, return nil instead of
|
||||
waiting for the process to be fully set up.*/)
|
||||
(Lisp_Object process, Lisp_Object key, Lisp_Object no_block)
|
||||
{
|
||||
Lisp_Object contact;
|
||||
|
||||
|
@ -1476,8 +1479,15 @@ set up yet, this function will block until socket setup has completed. */)
|
|||
|
||||
#ifdef DATAGRAM_SOCKETS
|
||||
|
||||
if (NETCONN_P (process))
|
||||
wait_for_socket_fds (process, "process-contact");
|
||||
if (NETCONN_P (process) && XPROCESS (process)->infd < 0)
|
||||
{
|
||||
/* Usually wait for the network process to finish being set
|
||||
* up. */
|
||||
if (!NILP (no_block))
|
||||
return Qnil;
|
||||
|
||||
wait_for_socket_fds (process, "process-contact");
|
||||
}
|
||||
|
||||
if (DATAGRAM_CONN_P (process)
|
||||
&& (EQ (key, Qt) || EQ (key, QCremote)))
|
||||
|
|
Loading…
Add table
Reference in a new issue