Here is the code with two things I tried as the ":filter" in ": my-pass-it-on-filter":
(defun my-pass-it-on-sentinel (proc _msg)
"Process entire output of PROC line-wise."
(when (and (eq (process-status proc) 'exit)
(zerop (process-exit-status proc))
(buffer-live-p (process-buffer proc)))
(with-current-buffer (process-buffer proc)
(mapc #'(lambda (x) x) (split-string (buffer-string) "\n" t))
(kill-buffer))))
(defun my-pass-it-on-filter (filePath proc str)
"Process each line produced by PROC in STR."
(when (buffer-live-p (process-buffer proc))
(with-current-buffer (process-buffer proc)
(insert str)
(goto-char (point-min))
(while (progn (skip-chars-forward "^\n")
(not (eobp)))
((lambda (line) (progn ((message ">>> %s" line)) (ignore-errors line))) (delete-and-extract-region (point-min) (point)))
(delete-char 1)))))
(make-process :name "my-proc2"
:buffer " *my-proc2*"
:command '("sh" "-c" "echo 1 && sleep 5 && echo 2")
:connection-type 'pipe
;; :filter #'(funcall 'my-pass-it-on-filter "/tmp/mytmp")
:filter #'(apply-partially 'my-pass-it-on-filter "/tmp/mytmp")
:sentinel #'my-pass-it-on-sentinel)