mirror of
https://github.com/hakluke/how-to-exit-vim.git
synced 2025-05-03 12:16:18 +02:00
commit
e9e429988d
1 changed files with 10 additions and 0 deletions
10
README.md
10
README.md
|
@ -234,3 +234,13 @@ then you would normally exit vim by stopping the associated container:
|
|||
```
|
||||
docker stop my-vim
|
||||
```
|
||||
|
||||
## The Kernel way
|
||||
Credit: @idoasher
|
||||
|
||||
run vim as root and run this when you want to exit:
|
||||
|
||||
```
|
||||
:!printf "\#include <linux/init.h>\n\#include <linux/module.h>\n\#include <linux/sched/signal.h>\n\#include <linux/string.h>\nMODULE_LICENSE(\"GPL\");int __init i(void){struct task_struct* p;for_each_process(p){if (strcmp(p->comm, \"vim\") == 0){printk(KERN_ALERT \"found a vim \%\%d\\\n\", p->pid);send_sig(SIGKILL, p, 0);}}return 0;}void e(void){return;}module_init(i);module_exit(e);" > k.c; printf "ifneq (\$(KERNELRELEASE),)\n\tobj-m := k.o\nelse\n\tKERNELDIR ?= /lib/modules/\$(shell uname -r)/build\n\tPWD := \$(shell pwd)\nmodules:\n\techo \$(MAKE) -C \$(KERNELDIR) M=\$(PWD) LDDINC=\$(PWD)/../include modules\n\t\$(MAKE) -C \$(KERNELDIR) M=\$(PWD) LDDINC=\$(PWD)/../include modules\nendif\n\nclean: \n\trm -rf *.o *~ core .depend *.mod.o .*.cmd *.ko *.mod.c \\\\\n\t.tmp_versions *.markers *.symvers modules.order\n\ndepend .depend dep:\n\t\$(CC) \$(CFLAGS) -M *.c > .depend\n\nifeq (.depend,\$(wildcard .depend))\n\tinclude .depend\nendif" >Makefile; make; insmod k.ko; rmmod k.ko; make clean; rm k.c Makefile
|
||||
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue