aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
authorPaul Eggert2019-01-15 10:18:45 -0800
committerPaul Eggert2019-01-15 10:21:09 -0800
commit9fc02ff5ea95c31a8d81eabb5634aa135fcd8786 (patch)
treec6a8b2db65efc5b51a184658a0672f89b625015e /doc/lispref
parent223e7b87872d4a010ae1c9a6f09a9c15aee46692 (diff)
downloademacs-9fc02ff5ea95c31a8d81eabb5634aa135fcd8786.tar.gz
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')
-rw-r--r--doc/lispref/processes.texi20
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
1859arrived. 1859arrived.
1860@end defun 1860@end defun
1861 1861
1862If a connection from a process contains buffered data,
1863@code{accept-process-output} can return non-@code{nil} even after the
1864process has exited. Therefore, although the following loop:
1865
1866@example
1867;; This loop contains a bug.
1868(while (process-live-p process)
1869 (accept-process-output process))
1870@end example
1871
1872@noindent
1873will often work, it has a race condition and can miss some output if
1874@code{process-live-p} returns @code{nil} while the connection still
1875contains data. Better is to write the loop like this:
1876
1877@example
1878(while (or (accept-process-output process)
1879 (process-live-p process)))
1880@end example
1881
1862@node Processes and Threads 1882@node Processes and Threads
1863@subsection Processes and Threads 1883@subsection Processes and Threads
1864@cindex processes, threads 1884@cindex processes, threads