代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <signal.h>
#include <unistd.h>
 
using namespace std;
 
void sig_handler( int sig)
{
    if(sig == SIGINT)
    {
        cout<<"ctrl+c has been keydownd"<<endl;
        exit(0);
    }
}
 
int main()
{
    signal(SIGINT, sig_handler);
    while(1)
    {
        sleep(10);
    }
                   
    return 0;
}

编译:

arm-linux-gnueabihf-g++ -o signal signal.cpp

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2023-03-13
  • 2022-12-23
  • 2022-12-23
  • 2022-02-15
  • 2023-03-20
  • 2022-12-23
  • 2021-12-25
相关资源
相似解决方案