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.
The subprocess output is given to the respective process 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.
Note that it is not guaranteed that this function will return as soon as some output is received. In particular, if PROCESS is nil, the function should not be expected to return before the timeout expires. The main purpose of this function is to allow process output to be read by Emacs, not to return as soon as any output is read.
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);
}