* `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);
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 */
" -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);
#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 */
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) {
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();
{
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
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;
{
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
debug("\n");
test_jobs();
- if ( serial_running <= 0)
+ while ( serial_num > 0 && serial_running < serial_max_running )
run_serial_job();
if ( save <= now ) {