emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unwind-protect within while-no-input


From: Spencer Baugh
Subject: unwind-protect within while-no-input
Date: Fri, 03 May 2024 08:45:33 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

I have some process which takes input on stdin; if I don't finish
sending the input on stdin for any reason, the process will sit around
forever waiting.  I'd like to delete the process rather than letting it
linger in that case.

My code (simplified somewhat) looks like:

(defun make-my-proc ()
  (let (proc finished-sending)
    (unwind-protect
        (progn
          (setq proc (make-process :command '("cat")))
          (process-send-string proc "some large string")
          (process-send-eof proc)
          (setq finished-sending t)
          proc)
      (unless finished-sending
        (delete-process proc)))))

However, this seems to be incorrect.  When this is called within a
(while-no-input (make-my-proc)) I sometimes get lingering processes
which haven't received their full input.

Is this because while-no-input can cause a signal to be thrown in the
unwind-forms before the delete-process call?

If so, how can I robustly delete the process?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]