aman
aman

Reputation: 338

Send a kill signal to self

I have a C++ code that runs a linux command, I want to simulate segfault i.e. 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?

Upvotes: 0

Views: 762

Answers (1)

Aman Chourasiya
Aman Chourasiya

Reputation: 1228

Sending kill signal to self can by done by putting this command

kill -9 $$

Upvotes: 1

Related Questions