* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: database.c,v 1.82 2008-05-11 10:56:28 thib Exp $ */
+ /* $Id: database.c,v 1.83 2008-05-11 15:05:51 thib Exp $ */
#include "fcron.h"
void resize_exe_array(void);
-#if !defined(HAVE_SETENV) || !defined(HAVE_UNSETENV)
+#if ! defined(HAVE_SETENV) || ! defined(HAVE_UNSETENV)
char env_tz[PATH_LEN];
#endif
resize_exe_array();
exe_array[exe_num].e_line = line;
-
- run_job(&exe_array[exe_num++]);
+ exe_num++;
+
+ /* run the job */
+ if ( run_job(&exe_array[exe_num-1]) != OK ) {
+ /* The job could not be run: remove it from the exe_array */
+ exe_array[exe_num-1].e_line->cl_numexe--;
+ exe_array[exe_num-1].e_line = NULL;
+ exe_num--;
+ }
}
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: job.c,v 1.73 2007-11-07 09:15:02 thib Exp $ */
+ /* $Id: job.c,v 1.74 2008-05-11 15:04:04 thib Exp $ */
#include "fcron.h"
}
}
-void
+int
run_job(struct exe_t *exeent)
- /* fork(), redirect outputs to a temp file, and execl() the task */
+ /* fork(), redirect outputs to a temp file, and execl() the task.
+ * Return ERR if it could not fork() the first time, OK otherwise. */
{
pid_t pid;
switch ( pid = fork() ) {
case -1:
error_e("Fork error : could not exec \"%s\"", line->cl_shell);
+ return ERR;
break;
case 0:
#ifndef RUN_NON_PRIVILEGED
if (change_user(line) < 0)
- return ;
+ exit(EXIT_ERR);
#endif
sig_dfl();
}
- /* execution never gets here */
+ /* execution should never gets here, but if it happened we exit with an error */
+ exit(EXIT_ERR);
}
default:
}
if ( close(pipe_pid_fd[0]) < 0 )
error_e("parent: could not close(pipe_pid_fd[0])");
- }
#ifdef CHECKRUNJOB
- debug("run_job(): finished reading pid of the job -- end of run_job().");
+ debug("run_job(): finished reading pid of the job -- end of run_job().");
#endif /* CHECKRUNJOB */
+ }
+
+ return OK;
+
}
void
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: job.h,v 1.9 2007-04-14 18:04:09 thib Exp $ */
+ /* $Id: job.h,v 1.10 2008-05-11 15:05:35 thib Exp $ */
#ifndef __JOB_H__
#define __JOB_H__
/* functions prototypes */
extern int change_user(struct cl_t *cl);
-extern void run_job(struct exe_t *exeent);
+extern int run_job(struct exe_t *exeent);
extern FILE *create_mail(struct cl_t *line, char *subject);
extern void launch_mailer(struct cl_t *line, FILE *mailf);