From 031f868620c255dd56adf33a7097ae019c50049b Mon Sep 17 00:00:00 2001 From: Morteza Bashsiz Date: Thu, 30 Nov 2023 15:15:26 +0100 Subject: [PATCH 1/2] Add C++ way --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index a023c9c..6991be8 100644 --- a/README.md +++ b/README.md @@ -831,3 +831,32 @@ echo "pub fn main() !noreturn { unreachable; }" > vimkill.zig; zig build-exe vim ``` This eventually [exhausts memory](https://github.com/ziglang/zig/issues/3461) on the machine which gives the OOM killer a chance to kill vim. + +## The C++ Way + +Credit: @MortezaBashsiz + +1. Run following command + +```bash +[~]>$ cat << EOF > /tmp/killvim.cpp +#include + +int main() { + system("killall vim"); + return 0; +} +EOF +``` + +2. Compile and build it + +```bash +[~]>$ g++ /tmp/killvim.cpp -o /usr/local/bin/killvim +``` + +3. Execute it + +```vim +:!killvim +``` From b162b0dd7ec60ffcc6f869caa80060a71fc1a852 Mon Sep 17 00:00:00 2001 From: Morteza Bashsiz Date: Thu, 30 Nov 2023 15:21:18 +0100 Subject: [PATCH 2/2] add sudo, and make it simpler --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6991be8..9d6c80a 100644 --- a/README.md +++ b/README.md @@ -852,11 +852,11 @@ EOF 2. Compile and build it ```bash -[~]>$ g++ /tmp/killvim.cpp -o /usr/local/bin/killvim +[~]>$ sudo g++ /tmp/killvim.cpp -o /usr/local/bin/killvim ``` -3. Execute it +3. Open another Terminal and execute it -```vim -:!killvim +```bash +killvim ```