diff options
| author | Jim Porter | 2022-06-26 18:27:20 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-06-26 18:27:20 +0200 |
| commit | 7faea4a15ead8307f59b055cfecba0928a9110c8 (patch) | |
| tree | 1352562edf4dbd97ddcf1a635982c3c59b09915a /lisp/eshell | |
| parent | 51f24fe2f418f2b7c4fa6732384bdd198f67f24f (diff) | |
| download | emacs-7faea4a15ead8307f59b055cfecba0928a9110c8.tar.gz emacs-7faea4a15ead8307f59b055cfecba0928a9110c8.zip | |
When closing an Eshell process target, send EOF three times
* lisp/eshell/esh-io.el (eshell-close-target): Send EOF 3 times.
* test/lisp/eshell/em-extpipe-tests.el (em-extpipe-tests--deftest):
Re-enable these tests on EMBA.
This patch is adapted by one from Ken Brown, who uncovered the reason
for this bug (bug#56025).
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/esh-io.el | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index 3644c1a18b5..c035890ddf0 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el | |||
| @@ -276,8 +276,20 @@ STATUS should be non-nil on successful termination of the output." | |||
| 276 | ;; If we're redirecting to a process (via a pipe, or process | 276 | ;; If we're redirecting to a process (via a pipe, or process |
| 277 | ;; redirection), send it EOF so that it knows we're finished. | 277 | ;; redirection), send it EOF so that it knows we're finished. |
| 278 | ((eshell-processp target) | 278 | ((eshell-processp target) |
| 279 | (if (eq (process-status target) 'run) | 279 | ;; According to POSIX.1-2017, section 11.1.9, sending EOF causes |
| 280 | (process-send-eof target))) | 280 | ;; all bytes waiting to be read to be sent to the process |
| 281 | ;; immediately. Thus, if there are any bytes waiting, we need to | ||
| 282 | ;; send EOF twice: once to flush the buffer, and a second time to | ||
| 283 | ;; cause the next read() to return a size of 0, indicating | ||
| 284 | ;; end-of-file to the reading process. However, some platforms | ||
| 285 | ;; (e.g. Solaris) actually require sending a *third* EOF. Since | ||
| 286 | ;; sending extra EOFs while the process is running shouldn't break | ||
| 287 | ;; anything, we'll just send the maximum we'd ever need. See | ||
| 288 | ;; bug#56025 for further details. | ||
| 289 | (let ((i 0)) | ||
| 290 | (while (and (<= (cl-incf i) 3) | ||
| 291 | (eq (process-status target) 'run)) | ||
| 292 | (process-send-eof target)))) | ||
| 281 | 293 | ||
| 282 | ;; A plain function redirection needs no additional arguments | 294 | ;; A plain function redirection needs no additional arguments |
| 283 | ;; passed. | 295 | ;; passed. |