Sample Header Ad - 728x90

What is the correct way to unconditionally kill a process?

4 votes
1 answer
1083 views
I have two hotkeys for interactively looking up and killing a process on Linux:
bindsym $mod+k exec --no-startup-id \
    "ps axo pid,cmd | sed 1d | dmenu -i -l 20 | awk '{print $1}' | xargs kill"
bindsym $mod+$sh+k exec --no-startup-id \
    "ps axo pid,cmd | sed 1d | dmenu -i -l 20 | awk '{print $1}' | xargs -s SIGSEGV kill"
The second hotkey is the "try-harder" version for unresponsive targets. What is the most appropriate signal to use here? It seems like an abuse of SIGSEGV since there is no underlying segmentation fault. signal(2) says > The signals SIGKILL and SIGSTOP cannot be caught or ignored but in my experience, it is very common for an unresponsive process to survive SIGKILL while dying to SIGSEGV. What is the "least wrong" way to mercilessly kill a process?
Asked by Fadeway (185 rep)
May 21, 2024, 10:22 AM
Last activity: May 21, 2024, 12:01 PM