diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-01-15 10:18:45 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-01-15 10:21:09 -0800 |
commit | 9fc02ff5ea95c31a8d81eabb5634aa135fcd8786 (patch) | |
tree | c6a8b2db65efc5b51a184658a0672f89b625015e /doc/lispref/processes.texi | |
parent | 223e7b87872d4a010ae1c9a6f09a9c15aee46692 (diff) | |
download | emacs-9fc02ff5ea95c31a8d81eabb5634aa135fcd8786.tar.gz emacs-9fc02ff5ea95c31a8d81eabb5634aa135fcd8786.tar.bz2 emacs-9fc02ff5ea95c31a8d81eabb5634aa135fcd8786.zip |
Fix accept-process-output/process-live-p confusion
* doc/lispref/processes.texi (Accepting Output):
Document the issue.
* lisp/net/tramp-adb.el (tramp-adb-parse-device-names):
* lisp/net/tramp-rclone.el (tramp-rclone-parse-device-names):
* lisp/net/tramp-smb.el (tramp-smb-wait-for-output):
* lisp/net/tramp.el (tramp-interrupt-process):
* test/src/process-tests.el (make-process/mix-stderr):
Fix code that uses accept-process-output and process-live-p.
Add FIXME comments as necessary.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-action-sudo):
* lisp/net/tramp.el (tramp-action-out-of-band):
Add FIXME comments as necessary.
Diffstat (limited to 'doc/lispref/processes.texi')
-rw-r--r-- | doc/lispref/processes.texi | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 72b164c5d45..afda8aede83 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -1859,6 +1859,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 work, 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 (or (accept-process-output process) + (process-live-p process))) +@end example + @node Processes and Threads @subsection Processes and Threads @cindex processes, threads |