Crowning
Crowning

Reputation: 45

How do I kill a running process in Emacs

When I compile the c++ file, emacs displays:

a compilation process is running;kill it?(y or n).

But y has no effect. How do I kill an active process in Emacs? there are many running processes in process list.

Upvotes: 4

Views: 2180

Answers (1)

assem
assem

Reputation: 2097

Not sure if there is a simpler, interactive solution - but using a bit of elisp, you can get a buffer of information of processes by:

(list-processes)

If you want a general purpose kill-all running processes, a simple example would be:

(mapcar 'delete-process (process-list))

(note that we used of process-list here).

If you want to delete a specific process by the name shown in the list processes buffer:

(delete-process (get-process "name of proc"))

And here is a simple way you might make this interactive: (if you do not use IDO, replace ido-completing-read with completing-read or similar)

(defun delete-process-interactive ()
  (interactive)
  (let ((pname (ido-completing-read "Process Name: " 
                    (mapcar 'process-name (process-list)))))

    (delete-process (get-process pname))))

And then run or key bind delete-process-interactive to tidy up your stray processes.

Though this is a solution, you might want to investigate what is causing this behavior further. For assistance with that from others, you will need to provide more information.

Upvotes: 5

Related Questions