PDA

View Full Version : C++: How to initiate kernel panic?



camper365
May 9th, 2009, 11:06 PM
I am trying to write a program that calls the panic() function in c++.
where is the library that does that, or do I need to get the linux-source?

stroyan
May 10th, 2009, 03:57 AM
As you say you are writing c++ code I can be fairly certain that you don't intend to write kernel code. Code in the kernel is never written in c++.
You can't just call some panic function from user space code to panic a linux system. If you are writing code that will run as root then you may able to use the sysrq mechanism to trigger a stack trace and shutdown similar to a panic. See http://en.wikipedia.org/wiki/Magic_SysRq_key and the /proc/sysrq and /proc/sysrq-trigger pseudo-files.

monkeyking
May 10th, 2009, 04:04 AM
Why do you want to crash the system?
I'me been trying to avoid that for many years now.

don't know if it helps,
but check this

http://www.faqs.org/docs/Linux-HOWTO/Linux-Crash-HOWTO.html

Sinkingships7
May 10th, 2009, 05:15 AM
This sounds vaguely like you're trying to write a virus of some sort...

cobolt01
May 10th, 2009, 09:03 AM
Yes, I couldn't imagine any situation that would require you to initiate a kernel panic that isn't malicious.