scron

simple cron daemon
git clone git://git.2f30.org/scron
Log | Files | Refs | README | LICENSE

commit 346a03fedb4343da0c1ef95befb5ae165071013e
parent 9360a9f2c7247ea35f271a344a547dab4adec571
Author: Ari Malinen <ari.malinen@gmail.com>
Date:   Wed, 25 Jun 2014 02:41:32 +0300

dont leave zombies

Diffstat:
MREADME | 7-------
Mcrond.c | 11+++++++++--
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/README b/README @@ -1,18 +1,11 @@ scron - simple cron daemon ========================== -about ------ -author: Ari Malinen -license: BSD 2-clause -git: https://github.com/defer-/scron - features -------- Schedule tasks. Single daemon, config and initscript. Log to stdout and syslog. -Good error handling. usage ----- diff --git a/crond.c b/crond.c @@ -4,15 +4,18 @@ #include <ctype.h> #include <time.h> #include <unistd.h> +#include <sys/wait.h> +#include <sys/types.h> #include <syslog.h> #define LEN 100 int main(int argc, char *argv[]) { char *ep, *col, line[LEN+1], config[LEN+1] = "/etc/crontab"; - int i, j; + int status, i, j; time_t t; struct tm *tm; + pid_t pid; FILE *fp; openlog(argv[0], LOG_CONS | LOG_PID, LOG_LOCAL1); @@ -78,7 +81,7 @@ int main(int argc, char *argv[]) { } else if (j == 5) { printf("run: %s", col); syslog(LOG_NOTICE, "run: %s", col); - switch (fork()) { + switch (pid = fork()) { case -1: fprintf(stderr, "error: job failed: %s", col); syslog(LOG_NOTICE, "error: job failed: %s", col); @@ -100,6 +103,10 @@ int main(int argc, char *argv[]) { } fclose(fp); + + while ((pid = wait(&status)) > 0) { + syslog(LOG_NOTICE, "job complete pid: %d return: %d", (int) pid, status); + } } closelog();