//The user of this model requires a delayed model reset //for visual interface purposes void FavoriteApplicationsModel::delayedReset() { QTimer::singleShot(DELAY, this, SLOT(fullReset())); }
int main(int argc, char *argv[]) { int button, buttonCount; #if defined(DEBUG) int daemonize = 0; #else int daemonize = 1; #endif // Setup signal handling before we start signal(SIGHUP, signal_handler); signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); signal(SIGQUIT, signal_handler); int c; while( (c = getopt(argc, argv, "nh|help")) != -1) { switch(c){ case 'h': PrintUsage(argc, argv); exit(0); break; case 'n': daemonize = 0; break; default: PrintUsage(argc, argv); exit(0); break; } } syslog(LOG_INFO, "%s daemon starting up", DAEMON_NAME); // Setup syslog logging - see SETLOGMASK(3) #if defined(DEBUG) setlogmask(LOG_UPTO(LOG_DEBUG)); openlog(DAEMON_NAME, LOG_CONS | LOG_NDELAY | LOG_PERROR | LOG_PID, LOG_USER); #else setlogmask(LOG_UPTO(LOG_INFO)); openlog(DAEMON_NAME, LOG_CONS, LOG_USER); #endif /* Our process ID and Session ID */ pid_t pid, sid; if (daemonize) { syslog(LOG_INFO, "starting the daemonizing process"); /* Fork off the parent process */ pid = fork(); if (pid < 0) { exit(EXIT_FAILURE); } /* If we got a good PID, then we can exit the parent process. */ if (pid > 0) { exit(EXIT_SUCCESS); } /* Change the file mode mask */ umask(0); /* Create a new SID for the child process */ sid = setsid(); if (sid < 0) { /* Log the failure */ exit(EXIT_FAILURE); } /* Change the current working directory */ if ((chdir("/")) < 0) { /* Log the failure */ exit(EXIT_FAILURE); } /* Close out the standard file descriptors */ close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); } //**************************************************** // TODO: Insert core of your daemon processing here //**************************************************** while(1){ button = buttonCheck(); if(button == 0){ //Debounce protector while(button == 0){ button = buttonCheck();} if(buttonCount == 0) buttonCount = 1; else buttonCount = 0; if(buttonCount == 1){ //Kill the code system("kill -9 'cat /var/run/studentCode.pid'"); //Print program termination message. system("wall /programKillMsg"); setLED(4); } //Reset the robot fullReset(); if( buttonCount == 0){ //Print message system("wall /resetMessage"); //Run the code again. system("/RUNCODE/runMe"); } usleep(500000); } } syslog(LOG_INFO, "%s daemon exiting", DAEMON_NAME); //**************************************************** // TODO: Free any allocated resources before exiting //**************************************************** exit(0); }