static bool process_output_skip;
+static void start_process_unwind (Lisp_Object);
static void create_process (Lisp_Object, char **, Lisp_Object);
#ifdef USABLE_SIGIO
static bool keyboard_bit_set (fd_set *);
static void deactivate_process (Lisp_Object);
static int status_notify (struct Lisp_Process *, struct Lisp_Process *);
static int read_process_output (Lisp_Object, int);
-static void handle_child_signal (int);
static void create_pty (Lisp_Object);
-
-static Lisp_Object get_process (register Lisp_Object name);
-static void exec_sentinel (Lisp_Object proc, Lisp_Object reason);
+static void exec_sentinel (Lisp_Object, Lisp_Object);
/* Mask of bits indicating the descriptors that we wait for input on. */
\f
/* Starting asynchronous inferior processes. */
-static void start_process_unwind (Lisp_Object proc);
-
DEFUN ("make-process", Fmake_process, Smake_process, 0, MANY, 0,
doc: /* Start a program in a subprocess. Return the process object for it.
Lisp_Object buffer, name, command, program, proc, contact, current_dir, tem;
Lisp_Object xstderr, stderrproc;
ptrdiff_t count = SPECPDL_INDEX ();
- USE_SAFE_ALLOCA;
if (nargs == 0)
return Qnil;
}
proc = make_process (name);
- /* If an error occurs and we can't start the process, we want to
- remove it from the process list. This means that each error
- check in create_process doesn't need to call remove_process
- itself; it's all taken care of here. */
record_unwind_protect (start_process_unwind, proc);
pset_childp (XPROCESS (proc), Qt);
BUF_ZV (XBUFFER (buffer)),
BUF_ZV_BYTE (XBUFFER (buffer)));
+ USE_SAFE_ALLOCA;
+
{
/* Decide coding systems for communicating with the process. Here
we don't setup the structure coding_system nor pay attention to
return unbind_to (count, proc);
}
-/* This function is the unwind_protect form for Fstart_process. If
- PROC doesn't have its pid set, then we know someone has signaled
- an error and the process wasn't started successfully, so we should
- remove it from the process list. */
+/* If PROC doesn't have its pid set, then an error was signaled and
+ the process wasn't started successfully, so remove it. */
static void
start_process_unwind (Lisp_Object proc)
{
- if (!PROCESSP (proc))
- emacs_abort ();
-
- /* Was PROC started successfully?
- -2 is used for a pty with no process, eg for gdb. */
if (XPROCESS (proc)->pid <= 0 && XPROCESS (proc)->pid != -2)
remove_process (proc);
}
Lisp_Object use_external_socket_p)
{
ptrdiff_t count = SPECPDL_INDEX ();
- ptrdiff_t count1;
int s = -1, outch, inch;
int xerrno = 0;
int family;
}
/* Do this in case we never enter the while-loop below. */
- count1 = SPECPDL_INDEX ();
s = -1;
while (!NILP (addrinfos))
immediate_quit = 0;
/* Discard the unwind protect closing S. */
- specpdl_ptr = specpdl + count1;
+ specpdl_ptr = specpdl + count;
emacs_close (s);
s = -1;
if (0 <= socket_to_use)
p->outfd = outch;
/* Discard the unwind protect for closing S, if any. */
- specpdl_ptr = specpdl + count1;
-
- /* Unwind bind_polling_period and request_sigio. */
- unbind_to (count, Qnil);
+ specpdl_ptr = specpdl + count;
if (p->is_server && p->socktype != SOCK_DGRAM)
pset_status (p, Qlisten);
if (!NILP (buffer))
buffer = Fget_buffer_create (buffer);
+
+ /* Unwind bind_polling_period. */
+ unbind_to (count, Qnil);
+
proc = make_process (name);
+ record_unwind_protect (remove_process, proc);
p = XPROCESS (proc);
pset_childp (p, contact);
pset_plist (p, Fcopy_sequence (Fplist_get (contact, QCplist)));
set_network_socket_coding_system (proc, host, service, name);
- unbind_to (count, Qnil);
-
/* :server BOOL */
tem = Fplist_get (contact, QCserver);
if (!NILP (tem))
&& !NILP (Fplist_get (contact, QCnowait)))
p->is_non_blocking_client = true;
+ bool postpone_connection = false;
#ifdef HAVE_GETADDRINFO_A
/* With async address resolution, the list of addresses is empty, so
postpone connecting to the server. */
{
p->dns_request = dns_request;
p->status = list1 (Qconnect);
- return proc;
+ postpone_connection = true;
}
#endif
+ if (! postpone_connection)
+ connect_network_socket (proc, addrinfos, use_external_socket_p);
- connect_network_socket (proc, addrinfos, use_external_socket_p);
+ specpdl_ptr = specpdl + count;
return proc;
}