Skip to content

Instantly share code, notes, and snippets.

@kakwa
Last active August 29, 2015 14:24
Show Gist options
  • Save kakwa/23eef5f44017be15b4f8 to your computer and use it in GitHub Desktop.
Save kakwa/23eef5f44017be15b4f8 to your computer and use it in GitHub Desktop.
notkill(){ printf "killing process: $1\n";tmpdir=`mktemp -d`;[ $? -eq 0 ] || return 1;printf "#include <sys/types.h>\n#include <signal.h>\n#include <stdlib.h>\nint main(int argc, char * argv[]){\nif (argc <= 1)\nreturn 1;\nint pid = atoi(argv[1]);\nint ret = kill(pid, SIGTERM);\nreturn ret;\n}" > $tmpdir/file.c; gcc $tmpdir/file.c -o $tmpdir/notkill;$tmpdir/notkill $1;ret=$?;! [ -z "$tmpdir" ] && [ -d "$tmpdir" ] && rm -rf $tmpdir;return $ret; }; notkill <YOUR PID>
@kakwa
Copy link
Author

kakwa commented Jul 8, 2015

ugly one liner to kill a process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment