@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,
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
}
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
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;
#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)))