return Qnil;
}
-\f
-static Lisp_Object
-list_processes_1 (Lisp_Object query_only)
-{
- register Lisp_Object tail;
- Lisp_Object proc, minspace;
- register struct Lisp_Process *p;
- char tembuf[300];
- int w_proc, w_buffer, w_tty;
- int exited = 0;
- Lisp_Object i_status, i_buffer, i_tty, i_command;
-
- w_proc = 4; /* Proc */
- w_buffer = 6; /* Buffer */
- w_tty = 0; /* Omit if no ttys */
-
- for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
- {
- int i;
-
- proc = Fcdr (XCAR (tail));
- p = XPROCESS (proc);
- if (NILP (p->type))
- continue;
- if (!NILP (query_only) && p->kill_without_query)
- continue;
- if (STRINGP (p->name)
- && ( i = SCHARS (p->name), (i > w_proc)))
- w_proc = i;
- if (!NILP (p->buffer))
- {
- if (NILP (BVAR (XBUFFER (p->buffer), name)))
- {
- if (w_buffer < 8)
- w_buffer = 8; /* (Killed) */
- }
- else if ((i = SCHARS (BVAR (XBUFFER (p->buffer), name)), (i > w_buffer)))
- w_buffer = i;
- }
- if (STRINGP (p->tty_name)
- && (i = SCHARS (p->tty_name), (i > w_tty)))
- w_tty = i;
- }
-
- XSETFASTINT (i_status, w_proc + 1);
- XSETFASTINT (i_buffer, XFASTINT (i_status) + 9);
- if (w_tty)
- {
- XSETFASTINT (i_tty, XFASTINT (i_buffer) + w_buffer + 1);
- XSETFASTINT (i_command, XFASTINT (i_tty) + w_tty + 1);
- }
- else
- {
- i_tty = Qnil;
- XSETFASTINT (i_command, XFASTINT (i_buffer) + w_buffer + 1);
- }
-
- XSETFASTINT (minspace, 1);
-
- set_buffer_internal (XBUFFER (Vstandard_output));
- BVAR (current_buffer, undo_list) = Qt;
-
- BVAR (current_buffer, truncate_lines) = Qt;
-
- write_string ("Proc", -1);
- Findent_to (i_status, minspace); write_string ("Status", -1);
- Findent_to (i_buffer, minspace); write_string ("Buffer", -1);
- if (!NILP (i_tty))
- {
- Findent_to (i_tty, minspace); write_string ("Tty", -1);
- }
- Findent_to (i_command, minspace); write_string ("Command", -1);
- write_string ("\n", -1);
-
- write_string ("----", -1);
- Findent_to (i_status, minspace); write_string ("------", -1);
- Findent_to (i_buffer, minspace); write_string ("------", -1);
- if (!NILP (i_tty))
- {
- Findent_to (i_tty, minspace); write_string ("---", -1);
- }
- Findent_to (i_command, minspace); write_string ("-------", -1);
- write_string ("\n", -1);
-
- for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
- {
- Lisp_Object symbol;
-
- proc = Fcdr (XCAR (tail));
- p = XPROCESS (proc);
- if (NILP (p->type))
- continue;
- if (!NILP (query_only) && p->kill_without_query)
- continue;
-
- Finsert (1, &p->name);
- Findent_to (i_status, minspace);
-
- if (p->raw_status_new)
- update_status (p);
- symbol = p->status;
- if (CONSP (p->status))
- symbol = XCAR (p->status);
-
- if (EQ (symbol, Qsignal))
- {
- Lisp_Object tem;
- tem = Fcar (Fcdr (p->status));
- Fprinc (symbol, Qnil);
- }
- else if (NETCONN1_P (p) || SERIALCONN1_P (p))
- {
- if (EQ (symbol, Qexit))
- write_string ("closed", -1);
- else if (EQ (p->command, Qt))
- write_string ("stopped", -1);
- else if (EQ (symbol, Qrun))
- write_string ("open", -1);
- else
- Fprinc (symbol, Qnil);
- }
- else if (SERIALCONN1_P (p))
- {
- write_string ("running", -1);
- }
- else
- Fprinc (symbol, Qnil);
-
- if (EQ (symbol, Qexit))
- {
- Lisp_Object tem;
- tem = Fcar (Fcdr (p->status));
- if (XFASTINT (tem))
- {
- sprintf (tembuf, " %d", (int) XFASTINT (tem));
- write_string (tembuf, -1);
- }
- }
-
- if (EQ (symbol, Qsignal) || EQ (symbol, Qexit) || EQ (symbol, Qclosed))
- exited++;
-
- Findent_to (i_buffer, minspace);
- if (NILP (p->buffer))
- insert_string ("(none)");
- else if (NILP (BVAR (XBUFFER (p->buffer), name)))
- insert_string ("(Killed)");
- else
- Finsert (1, &BVAR (XBUFFER (p->buffer), name));
-
- if (!NILP (i_tty))
- {
- Findent_to (i_tty, minspace);
- if (STRINGP (p->tty_name))
- Finsert (1, &p->tty_name);
- }
-
- Findent_to (i_command, minspace);
-
- if (EQ (p->status, Qlisten))
- {
- Lisp_Object port = Fplist_get (p->childp, QCservice);
- if (INTEGERP (port))
- port = Fnumber_to_string (port);
- if (NILP (port))
- port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil);
- sprintf (tembuf, "(network %s server on %s)\n",
- (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"),
- (STRINGP (port) ? SSDATA (port) : "?"));
- insert_string (tembuf);
- }
- else if (NETCONN1_P (p))
- {
- /* For a local socket, there is no host name,
- so display service instead. */
- Lisp_Object host = Fplist_get (p->childp, QChost);
- if (!STRINGP (host))
- {
- host = Fplist_get (p->childp, QCservice);
- if (INTEGERP (host))
- host = Fnumber_to_string (host);
- }
- if (NILP (host))
- host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil);
- sprintf (tembuf, "(network %s connection to %s)\n",
- (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"),
- (STRINGP (host) ? SSDATA (host) : "?"));
- insert_string (tembuf);
- }
- else if (SERIALCONN1_P (p))
- {
- Lisp_Object port = Fplist_get (p->childp, QCport);
- Lisp_Object speed = Fplist_get (p->childp, QCspeed);
- insert_string ("(serial port ");
- if (STRINGP (port))
- insert_string (SSDATA (port));
- else
- insert_string ("?");
- if (INTEGERP (speed))
- {
- sprintf (tembuf, " at %ld b/s", (long) XINT (speed));
- insert_string (tembuf);
- }
- insert_string (")\n");
- }
- else
- {
- Lisp_Object tem = p->command;
- while (1)
- {
- Lisp_Object tem1 = Fcar (tem);
- if (NILP (tem1))
- break;
- Finsert (1, &tem1);
- tem = Fcdr (tem);
- if (NILP (tem))
- break;
- insert_string (" ");
- }
- insert_string ("\n");
- }
- }
- if (exited)
- {
- status_notify (NULL);
- redisplay_preserve_echo_area (13);
- }
- return Qnil;
-}
-
-DEFUN ("list-processes", Flist_processes, Slist_processes, 0, 1, "P",
- doc: /* Display a list of all processes.
-If optional argument QUERY-ONLY is non-nil, only processes with
-the query-on-exit flag set will be listed.
-Any process listed as exited or signaled is actually eliminated
-after the listing is made. */)
- (Lisp_Object query_only)
-{
- internal_with_output_to_temp_buffer ("*Process List*",
- list_processes_1, query_only);
- return Qnil;
-}
DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0,
doc: /* Return a list of all processes. */)
function to handle the output. BUFFER may also be nil, meaning that
this process is not associated with any buffer.
-PROGRAM is the program file name. It is searched for in PATH. If
-nil, just associate a pty with the buffer. Remaining arguments are
-strings to give program as arguments.
+PROGRAM is the program file name. It is searched for in `exec-path'
+(which see). If nil, just associate a pty with the buffer. Remaining
+arguments are strings to give program as arguments.
If you want to separate standard output from standard error, invoke
the command through a shell and redirect one of them using the shell
syntax.
usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
- (int nargs, register Lisp_Object *args)
+ (size_t nargs, register Lisp_Object *args)
{
Lisp_Object buffer, name, program, proc, current_dir, tem;
register unsigned char **new_argv;
- register int i;
+ register size_t i;
int count = SPECPDL_INDEX ();
buffer = args[1];
new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
new_argv[nargs - 2] = 0;
- for (i = nargs - 3; i >= 0; i--)
+ for (i = nargs - 2; i-- != 0; )
{
new_argv[i] = SDATA (XCAR (tem));
tem = XCDR (tem);
create_pty (Lisp_Object process)
{
int inchannel, outchannel;
-
- /* Use volatile to protect variables from being clobbered by longjmp. */
- volatile int forkin, forkout;
- volatile int pty_flag = 0;
+ int pty_flag = 0;
inchannel = outchannel = -1;
#ifdef O_NOCTTY
/* Don't let this terminal become our controlling terminal
(in case we don't have one). */
- forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
+ int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
#else
- forkout = forkin = emacs_open (pty_name, O_RDWR, 0);
+ int forkout = emacs_open (pty_name, O_RDWR, 0);
#endif
- if (forkin < 0)
+ if (forkout < 0)
report_file_error ("Opening pty", Qnil);
#if defined (DONT_REOPEN_PTY)
/* In the case that vfork is defined as fork, the parent process
tty options setup. So we setup tty before forking. */
child_setup_tty (forkout);
#endif /* DONT_REOPEN_PTY */
-#else
- forkin = forkout = -1;
#endif /* not USG, or USG_SUBTTY_WORKS */
pty_flag = 1;
}
\(serial-process-configure :port "\\\\.\\COM13" :bytesize 7)
usage: (serial-process-configure &rest ARGS) */)
- (int nargs, Lisp_Object *args)
+ (size_t nargs, Lisp_Object *args)
{
struct Lisp_Process *p;
Lisp_Object contact = Qnil;
\(make-serial-process :port "/dev/tty.BlueConsole-SPP-1" :speed nil)
usage: (make-serial-process &rest ARGS) */)
- (int nargs, Lisp_Object *args)
+ (size_t nargs, Lisp_Object *args)
{
int fd = -1;
Lisp_Object proc, contact, port;
information, is available via the `process-contact' function.
usage: (make-network-process &rest ARGS) */)
- (int nargs, Lisp_Object *args)
+ (size_t nargs, Lisp_Object *args)
{
Lisp_Object proc;
Lisp_Object contact;
for (lres = res; lres; lres = lres->ai_next)
{
- int optn, optbits;
+ size_t optn;
+ int optbits;
#ifdef WINDOWSNT
retry_connect:
const struct ifflag_def *fp;
int fnum;
- any++;
+ any = 1;
for (fp = ifflag_table; flags != 0 && fp->flag_sym; fp++)
{
if (flags & fp->flag_bit)
register struct Lisp_Vector *p = XVECTOR (hwaddr);
int n;
- any++;
+ any = 1;
for (n = 0; n < 6; n++)
p->contents[n] = make_number (((unsigned char *)&rq.ifr_hwaddr.sa_data[0])[n]);
elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr);
#if defined(SIOCGIFNETMASK) && (defined(HAVE_STRUCT_IFREQ_IFR_NETMASK) || defined(HAVE_STRUCT_IFREQ_IFR_ADDR))
if (ioctl (s, SIOCGIFNETMASK, &rq) == 0)
{
- any++;
+ any = 1;
#ifdef HAVE_STRUCT_IFREQ_IFR_NETMASK
elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask));
#else
#if defined(SIOCGIFBRDADDR) && defined(HAVE_STRUCT_IFREQ_IFR_BROADADDR)
if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0)
{
- any++;
+ any = 1;
elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr));
}
#endif
#if defined(SIOCGIFADDR) && defined(HAVE_STRUCT_IFREQ_IFR_ADDR)
if (ioctl (s, SIOCGIFADDR, &rq) == 0)
{
- any++;
+ any = 1;
elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr));
}
#endif
struct buffer *old_buffer = current_buffer;
Lisp_Object old_window = selected_window;
- timer_delay = timer_check (1);
+ timer_delay = timer_check ();
/* If a timer has run, this might have changed buffers
an alike. Make read_key_sequence aware of that. */
}
else
#endif
- if (proc_buffered_char[channel] < 0)
{
+ int buffered = 0 <= proc_buffered_char[channel];
+ if (buffered)
+ {
+ chars[carryover] = proc_buffered_char[channel];
+ proc_buffered_char[channel] = -1;
+ }
#ifdef HAVE_GNUTLS
if (XPROCESS (proc)->gnutls_p)
nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
- chars + carryover, readmax);
+ chars + carryover + buffered,
+ readmax - buffered);
else
#endif
- nbytes = emacs_read (channel, chars + carryover, readmax);
+ nbytes = emacs_read (channel, chars + carryover + buffered,
+ readmax - buffered);
#ifdef ADAPTIVE_READ_BUFFERING
if (nbytes > 0 && p->adaptive_read_buffering)
{
delay += READ_OUTPUT_DELAY_INCREMENT * 2;
}
}
- else if (delay > 0 && (nbytes == readmax))
+ else if (delay > 0 && nbytes == readmax - buffered)
{
delay -= READ_OUTPUT_DELAY_INCREMENT;
if (delay == 0)
}
}
#endif
- }
- else
- {
- chars[carryover] = proc_buffered_char[channel];
- proc_buffered_char[channel] = -1;
-#ifdef HAVE_GNUTLS
- if (XPROCESS (proc)->gnutls_p)
- nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
- chars + carryover + 1, readmax - 1);
- else
-#endif
- nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1);
- if (nbytes < 0)
- nbytes = 1;
- else
- nbytes = nbytes + 1;
+ nbytes += buffered;
+ nbytes += buffered && nbytes <= 0;
}
p->decoding_carryover = 0;
outstream = p->filter;
if (!NILP (outstream))
{
- Lisp_Object obuffer, okeymap;
Lisp_Object text;
int outer_running_asynch_code = running_asynch_code;
int waiting = waiting_for_user_input_p;
/* No need to gcpro these, because all we do with them later
is test them for EQness, and none of them should be a string. */
+#if 0
+ Lisp_Object obuffer, okeymap;
XSETBUFFER (obuffer, current_buffer);
okeymap = BVAR (current_buffer, keymap);
+#endif
/* We inhibit quit here instead of just catching it so that
hitting ^G when a filter happens to be running won't screw
jmp_buf send_process_frame;
Lisp_Object process_sent_to;
-static SIGTYPE
+static void
send_process_trap (int ignore)
{
SIGNAL_THREAD_CHECK (SIGPIPE);
EMACS_INT rv;
struct coding_system *coding;
struct gcpro gcpro1;
- SIGTYPE (*volatile old_sigpipe) (int);
+ void (*volatile old_sigpipe) (int);
GCPRO1 (object);
while (this > 0)
{
int outfd = p->outfd;
- old_sigpipe = (SIGTYPE (*) (int)) signal (SIGPIPE, send_process_trap);
+ old_sigpipe = (void (*) (int)) signal (SIGPIPE, send_process_trap);
#ifdef DATAGRAM_SOCKETS
if (DATAGRAM_CHAN_P (outfd))
{
indirectly; if it does, that is a bug */
#ifdef SIGCHLD
-static SIGTYPE
+static void
sigchld_handler (int signo)
{
int old_errno = errno;
static void
exec_sentinel (Lisp_Object proc, Lisp_Object reason)
{
- Lisp_Object sentinel, obuffer, odeactivate, okeymap;
+ Lisp_Object sentinel, odeactivate;
register struct Lisp_Process *p = XPROCESS (proc);
int count = SPECPDL_INDEX ();
int outer_running_asynch_code = running_asynch_code;
/* No need to gcpro these, because all we do with them later
is test them for EQness, and none of them should be a string. */
odeactivate = Vdeactivate_mark;
+#if 0
+ Lisp_Object obuffer, okeymap;
XSETBUFFER (obuffer, current_buffer);
okeymap = BVAR (current_buffer, keymap);
+#endif
/* There's no good reason to let sentinels change the current
buffer, and many callers of accept-process-output, sit-for, and
do
{
int old_timers_run = timers_run;
- timer_delay = timer_check (1);
+ timer_delay = timer_check ();
if (timers_run != old_timers_run && do_display)
/* We must retry, since a timer may have requeued itself
and that could alter the time delay. */
defsubr (&Sprocess_contact);
defsubr (&Sprocess_plist);
defsubr (&Sset_process_plist);
- defsubr (&Slist_processes);
defsubr (&Sprocess_list);
defsubr (&Sstart_process);
defsubr (&Sserial_process_configure);