int main(int argc, char ** argv) { int fdmaster, fdslave; pid_t jobs[JOBS_MAX] = {}; test_init(argc, argv); if (num_jobs > JOBS_MAX) { err("%d jobs is too many", num_jobs); exit(1); } if (make_pty_pair(&fdmaster, &fdslave) < 0) { err("can't make pty pair: %m"); exit(1); } sleep(30); if (start_jobs(jobs, num_jobs, fdmaster, fdslave)) { err("failed to start jobs"); exit(1); } test_daemon(); test_waitsig(); if (finish_jobs(jobs, num_jobs, fdmaster, fdslave)) fail("failed to finish jobs"); else pass(); return 0; }
void job_dialog::on_start_selected(wxCommandEvent &) { size_t i; std::vector<int> jobs_to_start; for (i = 0; jobs.size() > i; ++i) if (lv_jobs->IsSelected(i)) jobs_to_start.push_back(i); if (!jobs_to_start.empty()) start_jobs(jobs_to_start); }
void job_dialog::on_start(wxCommandEvent &) { size_t i; std::vector<int> jobs_to_start; for (i = 0; jobs.size() > i; ++i) if (JOBS_PENDING == jobs[i].status) jobs_to_start.push_back(i); if (!jobs_to_start.empty()) start_jobs(jobs_to_start); }
int crond_main(int argc UNUSED_PARAM, char **argv) { time_t t2; unsigned rescan; unsigned sleep_time; unsigned opts; INIT_G(); /* "-b after -f is ignored", and so on for every pair a-b */ opt_complementary = "f-b:b-f:S-L:L-S" IF_FEATURE_CROND_D(":d-l") /* -l and -d have numeric param */ ":l+" IF_FEATURE_CROND_D(":d+"); opts = getopt32(argv, "l:L:fbSc:" IF_FEATURE_CROND_D("d:"), &G.log_level, &G.log_filename, &G.crontab_dir_name IF_FEATURE_CROND_D(,&G.log_level)); /* both -d N and -l N set the same variable: G.log_level */ if (!(opts & OPT_f)) { /* close stdin, stdout, stderr. * close unused descriptors - don't need them. */ bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv); } if (!(opts & OPT_d) && G.log_filename == NULL) { /* logging to syslog */ openlog(applet_name, LOG_CONS | LOG_PID, LOG_CRON); logmode = LOGMODE_SYSLOG; } //signal(SIGHUP, SIG_IGN); /* ? original crond dies on HUP... */ reopen_logfile_to_stderr(); xchdir(G.crontab_dir_name); log8("crond (busybox "BB_VER") started, log level %d", G.log_level); rescan_crontab_dir(); write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid"); /* Main loop */ t2 = time(NULL); rescan = 60; sleep_time = 60; for (;;) { struct stat sbuf; time_t t1; long dt; /* Synchronize to 1 minute, minimum 1 second */ t1 = t2; sleep(sleep_time - (time(NULL) % sleep_time)); t2 = time(NULL); dt = (long)t2 - (long)t1; reopen_logfile_to_stderr(); /* * The file 'cron.update' is checked to determine new cron * jobs. The directory is rescanned once an hour to deal * with any screwups. * * Check for time jump. Disparities over an hour either way * result in resynchronization. A negative disparity * less than an hour causes us to effectively sleep until we * match the original time (i.e. no re-execution of jobs that * have just been run). A positive disparity less than * an hour causes intermediate jobs to be run, but only once * in the worst case. * * When running jobs, the inequality used is greater but not * equal to t1, and less then or equal to t2. */ if (stat(G.crontab_dir_name, &sbuf) != 0) sbuf.st_mtime = 0; /* force update (once) if dir was deleted */ if (G.crontab_dir_mtime != sbuf.st_mtime) { G.crontab_dir_mtime = sbuf.st_mtime; rescan = 1; } if (--rescan == 0) { rescan = 60; rescan_crontab_dir(); } process_cron_update_file(); log5("wakeup dt=%ld", dt); if (dt < -60 * 60 || dt > 60 * 60) { bb_error_msg("time disparity of %ld minutes detected", dt / 60); /* and we do not run any jobs in this case */ } else if (dt > 0) { /* Usual case: time advances forward, as expected */ flag_starting_jobs(t1, t2); start_jobs(); sleep_time = 60; if (check_completions() > 0) { /* some jobs are still running */ sleep_time = 10; } } /* else: time jumped back, do not run any jobs */ } /* for (;;) */ return 0; /* not reached */ }