diff options
| -rw-r--r-- | src/process.c | 15 | ||||
| -rw-r--r-- | test/src/process-tests.el | 29 |
2 files changed, 41 insertions, 3 deletions
diff --git a/src/process.c b/src/process.c index 2df51cfd996..b602507765e 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1268,10 +1268,19 @@ The string argument is normally a multibyte string, except: | |||
| 1268 | if (NILP (filter)) | 1268 | if (NILP (filter)) |
| 1269 | filter = Qinternal_default_process_filter; | 1269 | filter = Qinternal_default_process_filter; |
| 1270 | 1270 | ||
| 1271 | pset_filter (p, filter); | ||
| 1272 | |||
| 1273 | if (p->infd >= 0) | 1271 | if (p->infd >= 0) |
| 1274 | set_process_filter_masks (p); | 1272 | { |
| 1273 | /* If filter WILL be t, stop reading output. */ | ||
| 1274 | if (EQ (filter, Qt) && !EQ (p->status, Qlisten)) | ||
| 1275 | delete_read_fd (p->infd); | ||
| 1276 | else if (/* If filter WAS t, then resume reading output. */ | ||
| 1277 | EQ (p->filter, Qt) | ||
| 1278 | /* Network or serial process not stopped: */ | ||
| 1279 | && !EQ (p->command, Qt)) | ||
| 1280 | add_process_read_fd (p->infd); | ||
| 1281 | } | ||
| 1282 | |||
| 1283 | pset_filter (p, filter); | ||
| 1275 | 1284 | ||
| 1276 | if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p)) | 1285 | if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p)) |
| 1277 | pset_childp (p, Fplist_put (p->childp, QCfilter, filter)); | 1286 | pset_childp (p, Fplist_put (p->childp, QCfilter, filter)); |
diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 7cccc5a02cb..7a6762a9226 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el | |||
| @@ -144,6 +144,35 @@ | |||
| 144 | (should (equal "hello stderr!\n" | 144 | (should (equal "hello stderr!\n" |
| 145 | (mapconcat #'identity (nreverse stderr-output) ""))))) | 145 | (mapconcat #'identity (nreverse stderr-output) ""))))) |
| 146 | 146 | ||
| 147 | (ert-deftest set-process-filter-t () | ||
| 148 | "Test setting process filter to t and back." ;; Bug#36591 | ||
| 149 | (with-temp-buffer | ||
| 150 | (let* ((print-level nil) | ||
| 151 | (print-length nil) | ||
| 152 | (proc (start-process | ||
| 153 | "test proc" (current-buffer) | ||
| 154 | (concat invocation-directory invocation-name) | ||
| 155 | "-Q" "--batch" "--eval" | ||
| 156 | (prin1-to-string | ||
| 157 | '(let (s) | ||
| 158 | (while (setq s (read-from-minibuffer "$ ")) | ||
| 159 | (princ s) | ||
| 160 | (princ "\n"))))))) | ||
| 161 | (set-process-query-on-exit-flag proc nil) | ||
| 162 | (send-string proc "one\n") | ||
| 163 | (should | ||
| 164 | (accept-process-output proc 1)) ; Read "one". | ||
| 165 | (should (equal (buffer-string) "$ one\n$ ")) | ||
| 166 | (set-process-filter proc t) ; Stop reading from proc. | ||
| 167 | (send-string proc "two\n") | ||
| 168 | (should-not | ||
| 169 | (accept-process-output proc 1)) ; Can't read "two" yet. | ||
| 170 | (should (equal (buffer-string) "$ one\n$ ")) | ||
| 171 | (set-process-filter proc nil) ; Resume reading from proc. | ||
| 172 | (should | ||
| 173 | (accept-process-output proc 1)) ; Read "two" from proc. | ||
| 174 | (should (equal (buffer-string) "$ one\n$ two\n$ "))))) | ||
| 175 | |||
| 147 | (ert-deftest start-process-should-not-modify-arguments () | 176 | (ert-deftest start-process-should-not-modify-arguments () |
| 148 | "`start-process' must not modify its arguments in-place." | 177 | "`start-process' must not modify its arguments in-place." |
| 149 | ;; See bug#21831. | 178 | ;; See bug#21831. |