2023-12-01 09:17:09 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <memory>
|
|
|
|
#include <thread>
|
|
|
|
#include <chrono>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
#include "async_scanner.h"
|
|
|
|
|
|
|
|
#define BUF_LEN_FOR_PID 64
|
|
|
|
|
|
|
|
|
|
|
|
static void sigHandler(int sig)
|
|
|
|
{
|
|
|
|
// if (sig == SIGINT || sig == SIGTERM)
|
|
|
|
// remove(MY_PID_FILE);
|
|
|
|
printf("exit now for signal: %d\n", sig);
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
/* Ctrl + C */
|
|
|
|
if (signal(SIGINT, sigHandler) == SIG_ERR)
|
|
|
|
{
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* kill pid / killall name */
|
|
|
|
if (signal(SIGTERM, sigHandler) == SIG_ERR)
|
|
|
|
{
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
async_scanner *scanner = new async_scanner();
|
2023-12-01 10:03:10 +00:00
|
|
|
int err = scanner->last_error();
|
|
|
|
|
|
|
|
if(err == 0)
|
2023-12-02 02:15:44 +00:00
|
|
|
{
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
if(getchar() == 'e')
|
|
|
|
{
|
|
|
|
if(getchar() == 'x')
|
|
|
|
{
|
|
|
|
if(getchar() == 'i')
|
|
|
|
{
|
|
|
|
if(getchar() == 't')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-01 10:03:10 +00:00
|
|
|
scanner->stop();
|
|
|
|
scanner->release();
|
|
|
|
|
2023-12-01 09:17:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|