Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I kill a running process in Emacs

Tags:

c++

emacs

process

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.

like image 857
Crowning Avatar asked Oct 24 '25 05:10

Crowning


1 Answers

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.

like image 145
assem Avatar answered Oct 26 '25 19:10

assem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!