From: thib Date: Tue, 29 May 2001 19:10:10 +0000 (+0000) Subject: added fcron's option -m X-Git-Tag: ver1564~257 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b9d94ef304b5f882809dd8b3d3e42be0b7866d3;p=fcron added fcron's option -m --- diff --git a/fcron.c b/fcron.c index ecd9ca6..ba6f194 100644 --- a/fcron.c +++ b/fcron.c @@ -21,11 +21,11 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: fcron.c,v 1.46 2001-05-28 18:48:27 thib Exp $ */ + /* $Id: fcron.c,v 1.47 2001-05-29 19:10:10 thib Exp $ */ #include "fcron.h" -char rcs_info[] = "$Id: fcron.c,v 1.46 2001-05-28 18:48:27 thib Exp $"; +char rcs_info[] = "$Id: fcron.c,v 1.47 2001-05-29 19:10:10 thib Exp $"; void main_loop(void); void check_signal(void); @@ -79,6 +79,9 @@ short int serial_array_index; /* the index of the first job */ short int serial_num; /* number of job being queued */ short int serial_running; /* number of running serial jobs */ +/* do not run more than this number of serial job simultaneously */ +short int serial_max_running = SERIAL_MAX_RUNNING; + struct lavg *lavg_array; /* jobs waiting for a given system load value */ short int lavg_array_size; /* size of lavg_array */ short int lavg_num; /* number of job being queued */ @@ -120,7 +123,9 @@ usage() " -f --foreground Stay in foreground.\n" " -b --background Go to background.\n" " -h --help Show this help message.\n" - " -s t --savetime t Save fcrontabs on disk every t sec.\n" + " -s t --savetime t Save fcrontabs on disk every t sec.\n" + " -m n --maxserial n Set to n the max number of running " + "serial jobs\n" ); exit(EXIT_ERR); @@ -226,12 +231,13 @@ parseopt(int argc, char *argv[]) #ifdef HAVE_GETOPT_H static struct option opt[] = { - {"debug",0,NULL,'d'}, - {"foreground",0,NULL,'f'}, - {"background",0,NULL,'b'}, - {"help",0,NULL,'h'}, - {"version",0,NULL,'V'}, - {"savetime",1,NULL,'s'}, + {"debug", 0, NULL, 'd'}, + {"foreground", 0, NULL, 'f'}, + {"background", 0, NULL, 'b'}, + {"help", 0, NULL, 'h'}, + {"version", 0, NULL, 'V'}, + {"savetime", 1, NULL, 's'}, + {"maxserial", 1, NULL, 'm'}, {0,0,0,0} }; #endif /* HAVE_GETOPT_H */ @@ -243,9 +249,9 @@ parseopt(int argc, char *argv[]) while(1) { #ifdef HAVE_GETOPT_H - c = getopt_long(argc, argv, "dfbhVs:", opt, NULL); + c = getopt_long(argc, argv, "dfbhVs:m:", opt, NULL); #else - c = getopt(argc, argv, "dfbhVs:"); + c = getopt(argc, argv, "dfbhVs:m:"); #endif /* HAVE_GETOPT_H */ if (c == EOF) break; switch (c) { @@ -271,6 +277,12 @@ parseopt(int argc, char *argv[]) die("Save time can only be set between 60 and %d.", LONG_MAX); break; + case 'm': + if ( (serial_max_running = strtol(optarg, NULL, 10)) <= 0 + || serial_max_running >= SHRT_MAX ) + die("Max running can only be set between 1 and %d.",SHRT_MAX); + break; + case ':': error("(parseopt) Missing parameter"); usage(); @@ -309,11 +321,6 @@ sighup_handler(int x) { signal(SIGHUP, sighup_handler); siginterrupt(SIGHUP, 0); - /* we don't call syslog() (by debug and explain) here anymore, because - * it may cause a crash if the signal is received during another call - * of syslog() */ -/* debug(""); */ -/* explain("SIGHUP signal received"); */ /* we don't call the synchronize_dir() function directly, because it may cause some problems if this signal is not received during the sleep @@ -325,11 +332,6 @@ RETSIGTYPE sigchild_handler(int x) /* call wait_chld() to take care of finished jobs */ { - /* we don't call syslog() (by debug and explain) here anymore, because - * it may cause a crash if the signal is received during another call - * of syslog() */ -/* debug(""); */ -/* debug("SIGCHLD signal received."); */ sig_chld = 1; @@ -344,11 +346,6 @@ sigusr1_handler(int x) { signal(SIGUSR1, sigusr1_handler); siginterrupt(SIGUSR1, 0); - /* we don't call syslog() (by debug and explain) here anymore, because - * it may cause a crash if the signal is received during another call - * of syslog() */ -/* debug(""); */ -/* explain("SIGUSR1 signal received"); */ /* we don't call the synchronize_dir() function directly, because it may cause some problems if this signal is not received during the sleep @@ -570,7 +567,7 @@ main_loop() debug("\n"); test_jobs(); - if ( serial_running <= 0) + while ( serial_num > 0 && serial_running < serial_max_running ) run_serial_job(); if ( save <= now ) {