Function: accept-process-output
accept-process-output is a function defined in process.c.
Signature
(accept-process-output &optional PROCESS SECONDS MILLISEC JUST-THIS-ONE)
Documentation
Allow any pending output from subprocesses to be read by Emacs.
It is given to their filter functions. Optional argument PROCESS means to return only after output is received from PROCESS or PROCESS closes the connection.
Optional second argument SECONDS and third argument MILLISEC specify a timeout; return after that much time even if there is no subprocess output. If SECONDS is a floating point number, it specifies a fractional number of seconds to wait. The MILLISEC argument is obsolete and should be avoided.
If optional fourth argument JUST-THIS-ONE is non-nil, accept output from PROCESS only, suspending reading output from other processes. If JUST-THIS-ONE is an integer, don't run any timers either. Return non-nil if we received any output from PROCESS (or, if PROCESS is nil, from any process) before the timeout expired or the corresponding connection was closed.
Probably introduced at or before Emacs version 22.1.
Source Code
// Defined in /usr/src/emacs/src/process.c
{
intmax_t secs;
int nsecs;
if (! NILP (process))
{
CHECK_PROCESS (process);
struct Lisp_Process *proc = XPROCESS (process);
/* Can't wait for a process that is dedicated to a different
thread. */
if (!NILP (proc->thread) && !BASE_EQ (proc->thread, Fcurrent_thread ()))
{
Lisp_Object proc_thread_name = XTHREAD (proc->thread)->name;
error ("Attempt to accept output from process %s locked to thread %s",
SDATA (proc->name),
STRINGP (proc_thread_name)
? SDATA (proc_thread_name)
: SDATA (Fprin1_to_string (proc->thread, Qt, Qnil)));
}
}
else
just_this_one = Qnil;
if (!NILP (millisec))
{ /* Obsolete calling convention using integers rather than floats. */
CHECK_FIXNUM (millisec);
if (NILP (seconds))
seconds = make_float (XFIXNUM (millisec) / 1000.0);
else
{
CHECK_FIXNUM (seconds);
seconds = make_float (XFIXNUM (millisec) / 1000.0 + XFIXNUM (seconds));
}
}
secs = 0;
nsecs = -1;
if (!NILP (seconds))
{
if (FIXNUMP (seconds))
{
if (XFIXNUM (seconds) > 0)
{
secs = XFIXNUM (seconds);
nsecs = 0;
}
}
else if (FLOATP (seconds))
{
if (XFLOAT_DATA (seconds) > 0)
{
struct timespec t = dtotimespec (XFLOAT_DATA (seconds));
secs = min (t.tv_sec, WAIT_READING_MAX);
nsecs = t.tv_nsec;
}
}
else
wrong_type_argument (Qnumberp, seconds);
}
else if (! NILP (process))
nsecs = 0;
return
((wait_reading_process_output (secs, nsecs, 0, 0,
Qnil,
!NILP (process) ? XPROCESS (process) : NULL,
(NILP (just_this_one) ? 0
: !FIXNUMP (just_this_one) ? 1 : -1))
<= 0)
? Qnil : Qt);
}