Simulate a Kernel Panic on Mac OS X

Not so far ago, I was lost on the net, and I found a piece of code to simulate a Kernel Panic in the osxbook site.
Well, and as we are Mac Users, we don’t see this kind of thing very often [TROLL]Not like on Windows[/TROLL], so I decided to share this little piece of code :P

#include <sys/types.h>
#include <sys/sysctl.h>

#define KERN_PANICINFO_TEST (KERN_PANICINFO_IMAGE + 2)

int main(void)
{
    size_t oldnewlen = 0;
    int mib[3] = { CTL_KERN, KERN_PANICINFO, KERN_PANICINFO_TEST };
    return sysctl(mib, 3, NULL, (void*)&oldnewlen, NULL, oldnewlen);
}
gcc panic_test.c -o panic_test
sudo ./panic_test

Result :
Kernel Panic simulation on Mac OS X

You have to be root to execute the program, because of sysctl()

In this site there is another post to show how you can change your panic screen, if you don’t know what to do…

One thought on “Simulate a Kernel Panic on Mac OS X

  1. I really find this is a great interesting subject. Never looked over this subject in this manner. If you are planning to create more articles about this subject, I will be back soon!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>