* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: config.h.in,v 1.5 2000-06-18 13:10:43 thib Exp $ */
+ /* $Id: config.h.in,v 1.6 2000-06-19 12:41:43 thib Exp $ */
/* *********************************************************** */
#define MAX_MSG 150 /* max length of a log message */
+/* *** time *** */
+#define FIRST_SLEEP 60 /* fcron sleep at least this time after startup
+ * before executing a job, to avoid to run jobs
+ * during system boot */
+#define SAVE_VARIATION 120 /* if a job is run at less than SAVE_VARIATION
+ * from normal time to save, save is performed
+ * after execution of the job.
+ * This is intended to avoid unneeded wakeups */
/* *** system dependent *** */
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: fcron.c,v 1.15 2000-06-18 15:28:15 thib Exp $ */
+ /* $Id: fcron.c,v 1.16 2000-06-19 12:42:32 thib Exp $ */
#include "fcron.h"
-char rcs_info[] = "$Id: fcron.c,v 1.15 2000-06-18 15:28:15 thib Exp $";
+char rcs_info[] = "$Id: fcron.c,v 1.16 2000-06-19 12:42:32 thib Exp $";
void main_loop(void);
void info(void);
if (foreground == 0) {
- /*
- * close stdin and stdout (stderr normally redirected by caller).
+ /* close stdin, stdout and stderr.
* close unused descriptors
- * optional detach from controlling terminal
- */
+ * optional detach from controlling terminal */
int fd;
pid_t pid;
close(fd);
}
- fclose(stdin);
- fclose(stdout);
-
if ( (i = open("/dev/null", O_RDWR)) < 0)
die_e("open: /dev/null:");
- dup2(i, 0);
- dup2(i, 1);
-
+ close(0); dup2(i, 0);
+ close(1); dup2(i, 1);
+ close(2); dup2(i, 2);
if(debug_opt) {
/* wait until child death and log his return value
/* synchronize save with jobs execution */
save = now + SAVE;
- if ( (stime = time_to_sleep(save)) < 60 )
+ if ( (stime = time_to_sleep(save)) < FIRST_SLEEP )
/* force first execution after 60 sec : execution of job during
system boot time is not what we want */
stime = 60;
gettimeofday(&tv, NULL);
usleep( 1000000 - tv.tv_usec );
+ now = time(NULL);
+
if (sig_chld > 0) {
wait_chld();
sig_chld = 0;
}
else if (sig_conf > 0) {
- now = time(NULL);
-
if (sig_conf == 1)
/* update configuration */
synchronize_dir(".");
else {
debug("\n");
- now = time(NULL);
-
test_jobs(now);
- if ( save - now <= 60 ) {
+ if ( save - now <= SAVE_VARIATION ) {
save = now + SAVE;
/* save all files */
save_file(NULL, NULL);