I have a C++ code that runs a linux command, I want to simulate segfault ie SIGSEGV while executing that linux command from by C++ code. So my code looks like this
int main(){
string cmd = "some linux command that should throw seg fault";
execute_linux_comand(cmd); // Want to simulate segfault coming while executing this command
}
What should I put in "cmd" so that it can send SIGSEGV to the sub-process created by calling this function?
Sending kill signal to self can by done by putting this command
kill -9 $$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.