ts.cpp
来自「linux 上http email 协议分析程序 主要能够处理大数据量的主干网」· C++ 代码 · 共 40 行
CPP
40 行
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <signal.h>#include <unistd.h> void sigtimeout(int sig);bool g_btimeOut=false;char strcmd[128];main(){ strcpy(strcmd,"mv tmp.s tmp.s$$"); system(strcmd); strcpy(strcmd,"kill $(ps -ea | grep cbtcphash | awk '{print $1}')"); signal(SIGALRM,sigtimeout); alarm(10); while(1) { if(g_btimeOut) { g_btimeOut=false; printf("timeout \n"); system(strcmd); } sleep(1); } } void sigtimeout(int sig) { g_btimeOut=true; signal(SIGALRM,sigtimeout); alarm(10); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?