Hacker News new | past | comments | ask | show | jobs | submit login
Emacs: Quickly Killing Processes (xenodium.com)
54 points by xenodium on Nov 13, 2022 | hide | past | favorite | 6 comments



If you're on linux, rofi[1] is a very versatile fuzzy-search graphical application. One of the typical ways to use it is to invoke it in script mode (see man rofi-script) with a shell script, where if called without arguments it invokes rofi against that script's stdout, and if called with arguments it runs a different command with that argument. This is nice because I don't have to switch to/open a new terminal or emacs, it's bound to a key I can invoke from anywhere in the graphical session. The kill process script is pretty simple (I filter out the path names from the nix store since I'm using nix)

  if [[ -z "$@" ]]; then
      echo -e "\0prompt\x1fKill Process"
      ps -ax | awk '{$2 = "" ; $3 = ""; $4 = ""; print $0}' | tail -n +2 | sed 's/\/nix\/store\/[^\/]*//'
  else
      kill $1
  fi
[1] https://github.com/davatorium/rofi


Rofi didn't work very well for me on Wayland, but there is a wlroots counterpart imaginatively named Wofi: https://cloudninja.pw/docs/wofi.html


There's a patched fork of rofi that supports wayland that I'm actually using, but linked the upstream in my OP for general reference: https://github.com/lbonn/rofi#wayland-support


Doesn't work if emacs itself is blocked waiting on the process.

I just tab over to a terminal and use pgrep/pkill for this.


I use aggressive-indent-mode with lsp and often clangd gives an error about "something something non added document" and emacs hangs. The only way to unblock it is to kill clangd from a shell.

Quite annoying, but haven't spent much time debugging it


Whether that matters depends on your use. Usually when I want to kill a process it's a program I'm working on and unrelated to emacs itself. This will be very useful for that and I can still always fire up an external terminal to kill things in the rare case where emacs itself is stuck waiting foe something and I can't C-g it. (Actually, since I use emacs EXWM as the window manager, in that situation I would Ctrl-Alt-Fkey to another tty and kill emacs if SIGUSR2 doesn't wake it up - a very rare situation indeed.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: