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-query-on-exit-flag, can be let-bound
to nil 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 7c51e10
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-query-on-exit-flag t
"Used as the query-on-exit flag for child Emacs processes.
Intended to be let-bound around a call to `async-start' or
`async-start-process'. If 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 (not async-process-query-on-exit-flag)))))
(set-process-sentinel
(get-buffer-process buf-err)
(lambda (proc _change)
Expand Down

0 comments on commit 7c51e10

Please sign in to comment.