/* Only MS-DOS does not define `subprocesses'. */
#ifdef subprocesses
-#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/un.h>
#endif
#endif
-#endif /* HAVE_SOCKETS */
#if defined(HAVE_SYS_IOCTL_H)
#include <sys/ioctl.h>
#if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5)
#include <fcntl.h>
#endif /* HAVE_PTYS and no O_NDELAY */
+#if defined(HAVE_NET_IF_H)
+#include <net/if.h>
+#endif /* HAVE_NET_IF_H */
#endif /* HAVE_SYS_IOCTL_H */
#ifdef NEED_BSDTTY
#include <bsdtty.h>
#endif
-/* Can we use SIOCGIFCONF and/or SIOCGIFADDR */
-#ifdef HAVE_SOCKETS
-#if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_NET_IF_H)
-/* sys/ioctl.h may have been included already */
-#ifndef SIOCGIFADDR
-#include <sys/ioctl.h>
-#endif
-#include <net/if.h>
-#endif
-#endif
-
#ifdef HAVE_SYS_WAIT
#include <sys/wait.h>
#endif
#include <resolv.h>
#endif
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
+
#endif /* subprocesses */
#include "lisp.h"
#if defined (USE_GTK) || defined (HAVE_GCONF)
#include "xgselect.h"
#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+extern int timers_run;
+
+Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
+Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
+Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
+Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
+Lisp_Object QCname, QCtype;
+\f
+/* Non-zero if keyboard input is on hold, zero otherwise. */
+
+static int kbd_is_on_hold;
+
+/* Nonzero means delete a process right away if it exits. */
+static int delete_exited_processes;
+
+/* Nonzero means don't run process sentinels. This is used
+ when exiting. */
+int inhibit_sentinels;
#ifdef subprocesses
/* QCfilter is defined in keyboard.c. */
extern Lisp_Object QCfilter;
-#ifdef HAVE_SOCKETS
#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork))
#define NETCONN1_P(p) (EQ ((p)->type, Qnetwork))
#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial))
#define SERIALCONN1_P(p) (EQ ((p)->type, Qserial))
-#else
-#define NETCONN_P(p) 0
-#define NETCONN1_P(p) 0
-#define SERIALCONN_P(p) 0
-#define SERIALCONN1_P(p) 0
-#endif /* HAVE_SOCKETS */
/* Define first descriptor number available for subprocesses. */
#define FIRST_PROC_DESC 3
#define SIGCHLD SIGCLD
#endif /* SIGCLD */
-extern char *get_operating_system_release (void);
+extern const char *get_operating_system_release (void);
/* Serial processes require termios or Windows. */
#if defined (HAVE_TERMIOS) || defined (WINDOWSNT)
#undef NON_BLOCKING_CONNECT
#else
#ifndef NON_BLOCKING_CONNECT
-#ifdef HAVE_SOCKETS
#ifdef HAVE_SELECT
#if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX)
#if defined (O_NONBLOCK) || defined (O_NDELAY)
#endif /* O_NONBLOCK || O_NDELAY */
#endif /* HAVE_GETPEERNAME || GNU_LINUX */
#endif /* HAVE_SELECT */
-#endif /* HAVE_SOCKETS */
#endif /* NON_BLOCKING_CONNECT */
#endif /* BROKEN_NON_BLOCKING_CONNECT */
#undef DATAGRAM_SOCKETS
#else
#ifndef DATAGRAM_SOCKETS
-#ifdef HAVE_SOCKETS
#if defined (HAVE_SELECT) || defined (FIONREAD)
#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE)
#define DATAGRAM_SOCKETS
#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */
#endif /* HAVE_SELECT || FIONREAD */
-#endif /* HAVE_SOCKETS */
#endif /* DATAGRAM_SOCKETS */
#endif /* BROKEN_DATAGRAM_SOCKETS */
static Lisp_Object get_process (register Lisp_Object name);
static void exec_sentinel (Lisp_Object proc, Lisp_Object reason);
-#endif /* subprocesses */
-
-extern int timers_run;
-
-Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
-Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
-Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
-Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
-Lisp_Object QCname, QCtype;
-\f
-/* Non-zero if keyboard input is on hold, zero otherwise. */
-
-static int kbd_is_on_hold;
-
-/* Nonzero means delete a process right away if it exits. */
-static int delete_exited_processes;
-
-#ifdef subprocesses
-
/* Mask of bits indicating the descriptors that we wait for input on. */
static SELECT_TYPE input_wait_mask;
/* Maximum number of bytes to send to a pty without an eof. */
static int pty_max_bytes;
-/* Nonzero means don't run process sentinels. This is used
- when exiting. */
-int inhibit_sentinels;
-
#ifdef HAVE_PTYS
#ifdef HAVE_PTY_H
#include <pty.h>
deactivate_process (proc);
}
-/* Setup coding systems of PROCESS. */
-
-void
-setup_process_coding_systems (Lisp_Object process)
-{
- struct Lisp_Process *p = XPROCESS (process);
- int inch = p->infd;
- int outch = p->outfd;
- Lisp_Object coding_system;
-
- if (inch < 0 || outch < 0)
- return;
-
- if (!proc_decode_coding_system[inch])
- proc_decode_coding_system[inch]
- = (struct coding_system *) xmalloc (sizeof (struct coding_system));
- coding_system = p->decode_coding_system;
- if (! NILP (p->filter))
- ;
- else if (BUFFERP (p->buffer))
- {
- if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters))
- coding_system = raw_text_coding_system (coding_system);
- }
- setup_coding_system (coding_system, proc_decode_coding_system[inch]);
-
- if (!proc_encode_coding_system[outch])
- proc_encode_coding_system[outch]
- = (struct coding_system *) xmalloc (sizeof (struct coding_system));
- setup_coding_system (p->encode_coding_system,
- proc_encode_coding_system[outch]);
-}
\f
DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0,
doc: /* Return t if OBJECT is a process. */)
return XPROCESS (proc)->type;
}
-#ifdef HAVE_SOCKETS
DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address,
1, 2, 0,
doc: /* Convert network ADDRESS from internal format to a string.
return Qnil;
}
-#endif
\f
static Lisp_Object
list_processes_1 (Lisp_Object query_only)
}
-#if 0 /* This doesn't work; see the note before sigchld_handler. */
-#ifdef USG
-#ifdef SIGCHLD
-/* Mimic blocking of signals on system V, which doesn't really have it. */
-
-/* Nonzero means we got a SIGCHLD when it was supposed to be blocked. */
-int sigchld_deferred;
-
-SIGTYPE
-create_process_sigchld ()
-{
- signal (SIGCHLD, create_process_sigchld);
-
- sigchld_deferred = 1;
-}
-#endif
-#endif
-#endif
-
void
create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
{
}
\f
-#ifdef HAVE_SOCKETS
-
/* Convert an internal struct sockaddr to a lisp object (vector or string).
The address family of sa is not included in the result. */
static const struct socket_options {
/* The name of this option. Should be lowercase version of option
name without SO_ prefix. */
- char *name;
+ const char *name;
/* Option level SOL_... */
int optlevel;
/* Option number SO_... */
#ifdef HAVE_GETADDRINFO
struct addrinfo ai, *res, *lres;
struct addrinfo hints;
- char *portstring, portbuf[128];
+ const char *portstring;
+ char portbuf[128];
#else /* HAVE_GETADDRINFO */
struct _emacs_addrinfo
{
UNGCPRO;
return proc;
}
-#endif /* HAVE_SOCKETS */
\f
-#if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
+#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
#ifdef SIOCGIFCONF
DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0,
return any ? res : Qnil;
}
#endif
-#endif /* HAVE_SOCKETS */
+#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */
/* Turn off input and output for process PROC. */
}
}
-/* Close all descriptors currently in use for communication
- with subprocess. This is used in a newly-forked subprocess
- to get rid of irrelevant descriptors. */
-
-void
-close_process_descs (void)
-{
-#ifndef DOS_NT
- int i;
- for (i = 0; i < MAXDESC; i++)
- {
- Lisp_Object process;
- process = chan_process[i];
- if (!NILP (process))
- {
- int in = XPROCESS (process)->infd;
- int out = XPROCESS (process)->outfd;
- if (in >= 0)
- emacs_close (in);
- if (out >= 0 && in != out)
- emacs_close (out);
- }
- }
-#endif
-}
\f
DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output,
0, 4, 0,
Otherwise, return true if we received input from any process. */
int
-wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
- wait_for_cell, wait_proc, just_wait_proc)
- int time_limit, microsecs, read_kbd, do_display;
- Lisp_Object wait_for_cell;
- struct Lisp_Process *wait_proc;
- int just_wait_proc;
+wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
+ int do_display,
+ Lisp_Object wait_for_cell,
+ struct Lisp_Process *wait_proc, int just_wait_proc)
{
register int channel, nfds;
SELECT_TYPE Available;
unbind_to (count, Qnil);
return nbytes;
}
-
-DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p,
- 0, 0, 0,
- doc: /* Returns non-nil if Emacs is waiting for input from the user.
-This is intended for use by asynchronous process output filters and sentinels. */)
- (void)
-{
- return (waiting_for_user_input_p ? Qt : Qnil);
-}
\f
/* Sending data to subprocess */
This function can evaluate Lisp code and can garbage collect. */
static void
-send_process (volatile Lisp_Object proc, unsigned char *volatile buf,
+send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
volatile int len, volatile Lisp_Object object)
{
/* Use volatile to protect variables from being clobbered by longjmp. */
traffic. */)
(Lisp_Object process, Lisp_Object current_group)
{
-#ifdef HAVE_SOCKETS
if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process)))
{
struct Lisp_Process *p;
p->command = Qt;
return process;
}
-#endif
#ifndef SIGTSTP
error ("No SIGTSTP support");
#else
traffic. */)
(Lisp_Object process, Lisp_Object current_group)
{
-#ifdef HAVE_SOCKETS
if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process)))
{
struct Lisp_Process *p;
p->command = Qnil;
return process;
}
-#endif
#ifdef SIGCONT
process_send_signal (process, SIGCONT, current_group, 0);
#else
{
int old_errno = errno;
Lisp_Object proc;
- register struct Lisp_Process *p;
- extern EMACS_TIME *input_available_clear_time;
+ struct Lisp_Process *p;
SIGNAL_THREAD_CHECK (signo);
\f
-/* Add DESC to the set of keyboard input descriptors. */
-
-void
-add_keyboard_wait_descriptor (int desc)
-{
- FD_SET (desc, &input_wait_mask);
- FD_SET (desc, &non_process_wait_mask);
- if (desc > max_keyboard_desc)
- max_keyboard_desc = desc;
-}
-
static int add_gpm_wait_descriptor_called_flag;
void
max_gpm_desc = desc;
}
-/* From now on, do not expect DESC to give keyboard input. */
-
-void
-delete_keyboard_wait_descriptor (int desc)
-{
- int fd;
- int lim = max_keyboard_desc;
-
- FD_CLR (desc, &input_wait_mask);
- FD_CLR (desc, &non_process_wait_mask);
-
- if (desc == max_keyboard_desc)
- for (fd = 0; fd < lim; fd++)
- if (FD_ISSET (fd, &input_wait_mask)
- && !FD_ISSET (fd, &non_keyboard_wait_mask)
- && !FD_ISSET (fd, &gpm_wait_mask))
- max_keyboard_desc = fd;
-}
-
void
delete_gpm_wait_descriptor (int desc)
{
Return true if we received input from any process. */
int
-wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
- wait_for_cell, wait_proc, just_wait_proc)
- int time_limit, microsecs, read_kbd, do_display;
- Lisp_Object wait_for_cell;
- struct Lisp_Process *wait_proc;
- int just_wait_proc;
+wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
+ int do_display,
+ Lisp_Object wait_for_cell,
+ struct Lisp_Process *wait_proc, int just_wait_proc)
{
register int nfds;
EMACS_TIME end_time, timeout;
/* The following functions are needed even if async subprocesses are
not supported. Some of them are no-op stubs in that case. */
+/* Add DESC to the set of keyboard input descriptors. */
+
+void
+add_keyboard_wait_descriptor (int desc)
+{
+#ifdef subprocesses
+ FD_SET (desc, &input_wait_mask);
+ FD_SET (desc, &non_process_wait_mask);
+ if (desc > max_keyboard_desc)
+ max_keyboard_desc = desc;
+#endif
+}
+
+/* From now on, do not expect DESC to give keyboard input. */
+
+void
+delete_keyboard_wait_descriptor (int desc)
+{
+#ifdef subprocesses
+ int fd;
+ int lim = max_keyboard_desc;
+
+ FD_CLR (desc, &input_wait_mask);
+ FD_CLR (desc, &non_process_wait_mask);
+
+ if (desc == max_keyboard_desc)
+ for (fd = 0; fd < lim; fd++)
+ if (FD_ISSET (fd, &input_wait_mask)
+ && !FD_ISSET (fd, &non_keyboard_wait_mask)
+ && !FD_ISSET (fd, &gpm_wait_mask))
+ max_keyboard_desc = fd;
+#endif /* subprocesses */
+}
+
+/* Setup coding systems of PROCESS. */
+
+void
+setup_process_coding_systems (Lisp_Object process)
+{
+#ifdef subprocesses
+ struct Lisp_Process *p = XPROCESS (process);
+ int inch = p->infd;
+ int outch = p->outfd;
+ Lisp_Object coding_system;
+
+ if (inch < 0 || outch < 0)
+ return;
+
+ if (!proc_decode_coding_system[inch])
+ proc_decode_coding_system[inch]
+ = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ coding_system = p->decode_coding_system;
+ if (! NILP (p->filter))
+ ;
+ else if (BUFFERP (p->buffer))
+ {
+ if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters))
+ coding_system = raw_text_coding_system (coding_system);
+ }
+ setup_coding_system (coding_system, proc_decode_coding_system[inch]);
+
+ if (!proc_encode_coding_system[outch])
+ proc_encode_coding_system[outch]
+ = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ setup_coding_system (p->encode_coding_system,
+ proc_encode_coding_system[outch]);
+#endif
+}
+
+/* Close all descriptors currently in use for communication
+ with subprocess. This is used in a newly-forked subprocess
+ to get rid of irrelevant descriptors. */
+
+void
+close_process_descs (void)
+{
+#ifndef DOS_NT
+ int i;
+ for (i = 0; i < MAXDESC; i++)
+ {
+ Lisp_Object process;
+ process = chan_process[i];
+ if (!NILP (process))
+ {
+ int in = XPROCESS (process)->infd;
+ int out = XPROCESS (process)->outfd;
+ if (in >= 0)
+ emacs_close (in);
+ if (out >= 0 && in != out)
+ emacs_close (out);
+ }
+ }
+#endif
+}
+
DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0,
doc: /* Return the (or a) process associated with BUFFER.
BUFFER may be a buffer or the name of one. */)
#endif /* subprocesses */
}
+DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p,
+ 0, 0, 0,
+ doc: /* Returns non-nil if Emacs is waiting for input from the user.
+This is intended for use by asynchronous process output filters and sentinels. */)
+ (void)
+{
+#ifdef subprocesses
+ return (waiting_for_user_input_p ? Qt : Qnil);
+#else
+ return Qnil;
+#endif
+}
+
/* Stop reading input from keyboard sources. */
void
memset (datagram_address, 0, sizeof datagram_address);
#endif
-#ifdef HAVE_SOCKETS
{
Lisp_Object subfeatures = Qnil;
const struct socket_options *sopt;
Fprovide (intern_c_string ("make-network-process"), subfeatures);
}
-#endif /* HAVE_SOCKETS */
#if defined (DARWIN_OS)
/* PTYs are broken on Darwin < 6, but are sometimes useful for interactive
processes. As such, we only change the default value. */
if (initialized)
{
- char *release = get_operating_system_release ();
+ const char *release = get_operating_system_release ();
if (!release || !release[0] || (release[0] < MIN_PTY_KERNEL_VERSION
&& release[1] == '.')) {
Vprocess_connection_type = Qnil;
defsubr (&Sserial_process_configure);
defsubr (&Smake_serial_process);
#endif /* HAVE_SERIAL */
-#ifdef HAVE_SOCKETS
defsubr (&Sset_network_process_option);
defsubr (&Smake_network_process);
defsubr (&Sformat_network_address);
-#endif /* HAVE_SOCKETS */
-#if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
+#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
#ifdef SIOCGIFCONF
defsubr (&Snetwork_interface_list);
#endif
#if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS)
defsubr (&Snetwork_interface_info);
#endif
-#endif /* HAVE_SOCKETS ... */
+#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */
#ifdef DATAGRAM_SOCKETS
defsubr (&Sprocess_datagram_address);
defsubr (&Sset_process_datagram_address);