int main(int argc, char **argv) { if (!is_single_proc_inst_running("athena")) { return 0; } const char *fifo_name = "/data/data/com.wujianai.rpk/__rpk__fifo__"; int pipe_fd = -1; if (access(fifo_name, F_OK) == -1) { //管道文件不存在 //创建命名管道 int res = mkfifo(fifo_name, 0777); if (res != 0) { printf("Could not create fifo %s\n", fifo_name); return 0; } } chmod(fifo_name, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); printf("Process %d opening FIFO O_WRONLY\n", getpid()); //以只写阻塞方式打开FIFO文件 pipe_fd = open(fifo_name, O_WRONLY); if (pipe_fd != -1) { //... init_input_event_list(); wait_input_event(pipe_fd); free_input_event_list(); //... close(pipe_fd); } return 0; }
int main(int argc ,char **argv) { if(!is_single_proc_inst_running(argv[0])) { printf("---has pid \n"); fflush(stdout); return -1; } char config_file[500]; int ret; if(argc>1 && access(argv[1], R_OK) == 0) { strcpy(config_file,argv[1]); } else if (access("SW.config", R_OK) == 0) { strcpy(config_file,"SW.config"); } else { cout<<"no config file can access"<<endl; } //SM_Manager *pSM_Manager = new SM_Manager; Switch_Control *pSM_Manager = new Switch_Control; printf("----welcom to switch \n"); fflush(stdout); pSM_Manager->init(config_file); while(1) { sleep(10000); } printf("----go to switch \n"); return 0; }
int main(int argc ,char **argv) { if(!is_single_proc_inst_running(argv[0])) { printf("---has pid \n"); return -1; } //setlocale(LC_ALL,"utf-8"); //SM_Manager *pSM_Manager = new SM_Manager; init("./sm.config"); SM_Control *pSM_Manager = new SM_Control; printf("----welcom to sm \n"); while(1) { sleep(10000); } printf("----go to sm \n"); return 0; }