I was writing a system call, done that and its working correctly. but I'm now looking for a way to crash the kernel somehow, and when does the kernel actually crash? I managed to put some pieces of code that would give me a few warnings and let the kernel compile correctly, but when does the actual crash occur?


2 Answers 2


To cause a kernel panic "attack" =):

echo c > /proc/sysrq-trigger
  • what do you mean?
    – Josh Aston
    Commented Mar 15, 2016 at 22:59
  • were you not asking how to trigger a kernel crash? From wikipedia: A kernel panic (sometimes abbreviated as KP[1]) is an action taken by an operating system upon detecting an internal fatal error from which it cannot safely recover. The term is largely specific to Unix and Unix-like systems
    – marc
    Commented Mar 15, 2016 at 23:02
  • yes but I need some code or any instructions that would cause this.
    – Josh Aston
    Commented Mar 15, 2016 at 23:10
  • execute the command above in a shell terminal and that's it... I didn't tried it, as I am right now working in the system.
    – marc
    Commented Mar 15, 2016 at 23:18
  • I need to have it part of the system call that I write
    – Josh Aston
    Commented Mar 15, 2016 at 23:19

Give the credit to mmmint. Here is the c code. Should be run as root.

#include <stdio.h>
int main(void)
    FILE *fp;
    fp = fopen("/proc/sysrq-trigger", "a");
    if (fp != NULL) {
        fprintf(fp, "c");
    printf("Are you running as root?");

and I know it works :-(

  • 2
    I didn't wanteed to test it...hehehe...By the way, you could also use the kernel function: void panic(const char *fmt, ...) linux.die.net/man/3/panic
    – marc
    Commented Mar 16, 2016 at 8:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .