Function: process-contact

process-contact is a function defined in process.c.

Signature

(process-contact PROCESS &optional KEY NO-BLOCK)

Documentation

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
(HOST SERVICE) for a network connection or (PORT SPEED) for a serial
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. If the optional NO-BLOCK parameter is specified, return nil instead of waiting for the process to be fully set up.

Probably introduced at or before Emacs version 20.1.

Source Code

// Defined in /usr/src/emacs/src/process.c
{
  Lisp_Object contact;

  CHECK_PROCESS (process);
  contact = XPROCESS (process)->childp;

#ifdef DATAGRAM_SOCKETS

  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)))
    contact = Fplist_put (contact, QCremote,
			  Fprocess_datagram_address (process));
#endif

  if ((!NETCONN_P (process) && !SERIALCONN_P (process) && !PIPECONN_P (process))
      || EQ (key, Qt))
    return contact;
  if (NILP (key) && NETCONN_P (process))
    return list2 (Fplist_get (contact, QChost),
		  Fplist_get (contact, QCservice));
  if (NILP (key) && SERIALCONN_P (process))
    return list2 (Fplist_get (contact, QCport),
		  Fplist_get (contact, QCspeed));
  /* FIXME: Return a meaningful value (e.g., the child end of the pipe)
     if the pipe process is useful for purposes other than receiving
     stderr.  */
  if (NILP (key) && PIPECONN_P (process))
    return Qt;
  return Fplist_get (contact, key);
}