Skip to content

Commit

Permalink
Add variable to set process-query-on-exit-flag
Browse files Browse the repository at this point in the history
This can't reliably be done by the caller of async-start, because
make-process will create an extra process for the stderr buffer that
cannot be easily found based on the returned process from async-start.

The new variable, async-process-noquery-on-exit, can be let-bound to
t around a call to async-start in order to cause the parent Emacs to
silently kill the child Emacs if the user quits the parent.

This can be useful for async processes run in timers for things like
notifications, where the user doesn't really care if a running process
actually finishes, since they're killing Emacs.
  • Loading branch information
bcc32 committed Mar 23, 2024
1 parent a368df0 commit 937e262
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion async.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ When this is nil child Emacs will hang forever when a user interaction
for password is required unless a password is stored in a \".authinfo\" file."
:type 'boolean)

(defvar async-process-noquery-on-exit nil
"Used as the :noquery argument to `make-process'.
Intended to be let-bound around a call to `async-start' or
`async-start-process'. If non-nil, the child Emacs process will
be silently killed if the user exits the parent Emacs.")

(defvar async-debug nil)
(defvar async-send-over-pipe t)
(defvar async-in-child-emacs nil)
Expand Down Expand Up @@ -426,7 +433,8 @@ working directory."
:name name
:buffer buf
:stderr buf-err
:command (cons program program-args)))))
:command (cons program program-args)
:noquery async-process-noquery-on-exit))))
(set-process-sentinel
(get-buffer-process buf-err)
(lambda (proc _change)
Expand Down

0 comments on commit 937e262

Please sign in to comment.