diff options
| author | Paul Eggert | 2019-01-15 10:18:45 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-01-15 10:21:09 -0800 |
| commit | 9fc02ff5ea95c31a8d81eabb5634aa135fcd8786 (patch) | |
| tree | c6a8b2db65efc5b51a184658a0672f89b625015e /doc/lispref | |
| parent | 223e7b87872d4a010ae1c9a6f09a9c15aee46692 (diff) | |
| download | emacs-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.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 | |||
| 1859 | arrived. | 1859 | arrived. |
| 1860 | @end defun | 1860 | @end defun |
| 1861 | 1861 | ||
| 1862 | If a connection from a process contains buffered data, | ||
| 1863 | @code{accept-process-output} can return non-@code{nil} even after the | ||
| 1864 | process 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 | ||
| 1873 | will 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 | ||
| 1875 | contains 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 |