这是程序的要点:
while(true)
{
//bunch of codes that gets data from port ,
//if there is no data it waits here .
}
我用的是linux,有没有内置的支持像Ctrl+C这样的按键。我可以使用signal(SIGINT, signal_callback_handler);捕捉到这一点,但是Ctrl+C有一些问题,因为它会给出错误。
我想在按键时跳出这个循环,这是可能的吗?如果是,如何操作。
我有一个运行linux命令的C++代码,我想模拟分段错误,即SIGSEGV,同时通过C++代码执行C++命令。所以我的代码是这样的
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
}
我应该放什么"cmd“,这样它才能将SIGSEGV发送到通过调用该函数创建的子进程?