67 lines
953 B
C++
67 lines
953 B
C++
#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 "DisplayCenter.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);
|
|
}
|
|
|
|
int err = 0;
|
|
DisplayCenter monitor;
|
|
|
|
monitor.PutMsg(DisType::Dis_Welcome, 0, ClearScreen::All);
|
|
if(err == 0)
|
|
{
|
|
while(1)
|
|
{
|
|
if(getchar() == 'e')
|
|
{
|
|
if(getchar() == 'x')
|
|
{
|
|
if(getchar() == 'i')
|
|
{
|
|
if(getchar() == 't')
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
} |