Skip to content

Instantly share code, notes, and snippets.

@matthewbauer
Last active December 4, 2017 22:41
Show Gist options
  • Save matthewbauer/1563ec69d8f99bbaf6788a8e696c9540 to your computer and use it in GitHub Desktop.
Save matthewbauer/1563ec69d8f99bbaf6788a8e696c9540 to your computer and use it in GitHub Desktop.
#!/bin/sh
# to run this, use the following:
# curl https://matthewbauer.us/kernel-panic.sh | sh
cfile=$(mktemp).c
cat <<EOF >> $cfile
#include <unistd.h>
#include <sys/syscall.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
int main() {
int result;
sleep(1);
for (int i = 0; i < 20; i++) {
result = syscall(SYS_kill, -1, SIGKILL, 0);
printf("result:%i,errno:%i (%s)\n", result, errno, strerror(errno));
}
}
EOF
ofile=$(mktemp).o
gcc $cfile -o $ofile
$ofile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment