void Controller::run(uint32_t numThreads, uint32_t maxThreads, double monitorInterval) { maxThreads_ = maxThreads; // start all of the worker threads startWorkers(numThreads); // drive the monitor runMonitor(monitorInterval); }
/** * waitcmd.c * * moniters files and invokescertain commands when accessed or modified. * If no command line argumants are given then commands are read from the * waitcmd.ini file and monitoring starts for all files mentioned. * If command line argumants are given then they are added to the ini file. * If an instance of waitcmd is already running then it will be refreshed * to include the new commands. * Monitoring is not started when new commands are given. */ int main (int argc, char *argv[]) { if(argc > 1) { if(argv[1] == "-h") printHelp(); else addToIni(argc, argv); } else readIni() runMonitor(); printf("Monitoring files (for help type \"waitcmd -h\")\n"); return 0; }
int main(int argc, char **argv) { struct sigaction action; int exitCode; parseArgs(argc,argv); initLogs(); if (keepAsDaemon) { LOG_N("Trying to keep as a daemon..."); if (daemon(false,false)<0) { LOG_E(strerror(errno)); LOG_W("... continuing daemonless"); } else { LOG_N("... Success "); } } memset(&action,0,sizeof(action)); action.sa_handler =signalHandler; sigaction(SIGHUP,&action,NULL); sigaction(SIGTERM,&action,NULL); // signal(SIGHUP,signalHandler); /* catch hangup signal */ // signal(SIGTERM,signalHandler); /* catch kill signal */ exitCode = runMonitor(); return exitCode; //return EXIT_SUCCESS; }
void Process::run() { if (tnt::TntConfig::it().daemon) { log_debug("run daemon-mode"); // We receive the writing-end of the notify pipe. // After successful initialization we need to write a byte to this fd. cxxtools::posix::Pipe mainPipe; cxxtools::posix::Fork fork; if (fork.parent()) { log_debug("close write-fd of main-pipe"); mainPipe.closeWriteFd(); log_debug("wait for child to initialize"); mainPipe.read(); log_debug("child initialized"); fork.setNowait(); } else { log_debug("close read-fd of main-pipe"); mainPipe.closeReadFd(); runMonitor(mainPipe); } } else { log_debug("run"); initWorker(); log_debug("do work"); doWork(); } }