只能起一个进程 LINUX
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
/*
* main.cpp
*
* Created on: Feb 9, 2010
* Author: weiyu wang
*/
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <semaphore.h>
#include <fcntl.h>
#include "awtools.h"
#include "awlogger.h"
#include "qmcontroller.h"
using namespace std;
using namespace AWTookit;
sem_t* sem;
void sig_proc(int sig)
{
signal(SIGINT, SIG_DFL);
AWLOG_INFO("Ctrl + C, quit controller ......");
sem_post(sem);
exit(0);
}
int main(int argc, char** argv) {
signal(SIGINT, sig_proc);
AWLOG_INIT("qmcontroller");
sem = sem_open("qmanager", O_CREAT, 0644, 1);
if (-1 == sem_trywait(sem))
return 0;
controller().run();
sem_post(sem);
return 0;
}
* main.cpp
*
* Created on: Feb 9, 2010
* Author: weiyu wang
*/
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <semaphore.h>
#include <fcntl.h>
#include "awtools.h"
#include "awlogger.h"
#include "qmcontroller.h"
using namespace std;
using namespace AWTookit;
sem_t* sem;
void sig_proc(int sig)
{
signal(SIGINT, SIG_DFL);
AWLOG_INFO("Ctrl + C, quit controller ......");
sem_post(sem);
exit(0);
}
int main(int argc, char** argv) {
signal(SIGINT, sig_proc);
AWLOG_INIT("qmcontroller");
sem = sem_open("qmanager", O_CREAT, 0644, 1);
if (-1 == sem_trywait(sem))
return 0;
controller().run();
sem_post(sem);
return 0;
}