Subject: Re: bug#51177: 29.0.50; stop-process on pipes

From: Helmut Eller <[email-masked]>
Date: Thu, 11 Nov 2021 20:47:57 +0100

I have another problem with stopped output.  In this example:

;;; -*- lexical-binding:t -*-

(ert-deftest test-read-after-exit ()
  (let* ((output "")
	 (filter (lambda (p s) (setq output (concat output s))))
	 (sentinel (lambda (p _)
		     (set-process-filter p filter)
		     (while (accept-process-output p 0))))
	 (proc (make-process :command '("printf" "foo")
			     :name "test-proc"
			     :filter t
			     :sentinel sentinel
			     :connection-type 'pipe)))
    (while (process-live-p proc)
      (accept-process-output proc 0.2))
    (set-process-filter proc filter)
    (while (accept-process-output proc 0))
    (should (equal output "foo"))))

the filter function is never called.

We could say that reading the process's output after the process has
terminated is an unreasonable request.  However, I would like to propose
that, in status_notify, the sentinel function should be called before
closing the file descriptors.  That way, the sentinel can read the
buffered output as suggested in the example.

Helmut