scron

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

commit 85f4608625c990e247a73d9112737075c76bf6ca
parent a4f52e4c6b09506f42357e8d3738b67824de9b44
Author: Ari Malinen <ari.malinen@gmail.com>
Date:   Tue, 10 Jun 2014 23:49:00 +0300

improved error handling

Diffstat:
Adcron | 0
Mdcron.c | 11+++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/dcron b/dcron Binary files differ. diff --git a/dcron.c b/dcron.c @@ -25,7 +25,11 @@ int main(int argc, char *argv[]) { fprintf(stderr, "usage: %s [-h = help] [-d = daemon]\n", argv[0]); return 1; } else if (argc > 1 && !strcmp("-d", argv[1])) { - daemon(1, 0); + if (daemon(1, 0) != 0) { + fprintf(stderr, "error: failed to daemonize\n"); + syslog(LOG_NOTICE, "error: failed to daemonize\n"); + return 1; + } } openlog(argv[0], LOG_CONS | LOG_PID, LOG_LOCAL1); @@ -95,7 +99,10 @@ int main(int argc, char *argv[]) { (wday == -1 || wday == tm->tm_wday)) { printf("run: %s", cmd); syslog(LOG_NOTICE, "run: %s", cmd); - system(cmd); + if (system(cmd) != 0) { + fprintf(stderr, "error: job failed\n"); + syslog(LOG_NOTICE, "error: job failed\n"); + } } } }