Commit f90a3360 authored by Eli Zaretskii's avatar Eli Zaretskii

Backport doc improvement in ELisp manual

* doc/lispref/processes.texi (Accepting Output): Backport:
document how do avoid race conditions while waiting for all of
the process's output to arrive.
parent 037970f1
Pipeline #1372 passed with stage
in 26 minutes and 18 seconds
......@@ -1834,6 +1834,26 @@ corresponding connection contains buffered data. The function returns
arrived.
@end defun
If a connection from a process contains buffered data,
@code{accept-process-output} can return non-@code{nil} even after the
process has exited. Therefore, although the following loop:
@example
;; This loop contains a bug.
(while (process-live-p process)
(accept-process-output process))
@end example
@noindent
will often read all output from @var{process}, it has a race condition
and can miss some output if @code{process-live-p} returns @code{nil}
while the connection still contains data. Better is to write the loop
like this:
@example
(while (accept-process-output process))
@end example
@node Processes and Threads
@subsection Processes and Threads
@cindex processes, threads
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment