#include <iostream>
#include <csignal>
#include <unistd.h>
using namespace std;
void signalHandler(int signum) {
cout << "interrupt signal (" << signum << ") received.\n";
exit(signum);
}
int main(){
int i = 0;
signal(SIGINT,signalHandler);
while(++i){
cout << "going to sleep...." << endl;
if (i == 3) {
raise(SIGINT);
}
sleep(1);
}
return 0;
}
c++ raise
猜你喜欢
转载自www.cnblogs.com/niconico-girl/p/9709780.html
今日推荐
周排行