diff options
Diffstat (limited to 'doc')
| -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 |