Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Emacs stop asking "Active processes exist; kill them and exit anyway"

Tags:

emacs

In spite of all the advice that it is a bad idea, I still would like Emacs to stop asking me "Active processes exist; kill them and exit anyway" when I hit C-c C-x. I would like it to simply kill all active processes without asking.

How can I accomplish this?

like image 221
Adam Avatar asked Apr 24 '10 23:04

Adam


People also ask

How do I stop a process in Emacs?

More generally: You can use M-: (kill-process PROCESS) RET , where PROCESS "may be a process, a buffer, or the name of a process or buffer", with those names being as they appear in the output of list-processes .

How do I kill a program in Emacs?

If you started Emacs from a terminal, the parent process normally resumes control. The low-level primitive for killing Emacs is kill-emacs . This command calls the hook kill-emacs-hook , then exits the Emacs process and kills it.


3 Answers

This snippet (goes into your .emacs customization file) will temporarily make Emacs believes that there is no active process when you kill it, and therefore you won't get the annoying prompt.

(require 'cl-lib) (defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)   "Prevent annoying \"Active processes exist\" query when you quit Emacs."   (cl-letf (((symbol-function #'process-list) (lambda ())))     ad-do-it)) 
like image 52
polyglot Avatar answered Oct 07 '22 16:10

polyglot


You can accomplish this by setting query-on-exit flag for each process to nil. You can use a hook to do this automatically when executing a command interpreter:

(add-hook 'comint-exec-hook        (lambda () (set-process-query-on-exit-flag (get-buffer-process (current-buffer)) nil))) 
like image 42
Jürgen Hötzel Avatar answered Oct 07 '22 17:10

Jürgen Hötzel


The next version of Emacs (25.3 or 26.1) will have a new customization option confirm-kill-processes to make this simpler. You can then say M-x customize-variable RET confirm-kill-processes RET and set the variable to nil to suppress the confirmation prompt.

like image 22
Philipp Avatar answered Oct 07 '22 16:10

Philipp