From: Marcela Maslanova Date: Mon, 29 Oct 2007 15:00:57 +0000 (+0100) Subject: Some cron jobs failed without error message. If the job had X-Git-Tag: v4.3~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95c2295cf1d014b407ecfe8b2780d065d9eb334b;p=cronie Some cron jobs failed without error message. If the job had too "big" output and no mail client set, then only a part from job was done. The reason was pipe, which has restricted size. rh bugzilla #247228 --- diff --git a/src/popen.c b/src/popen.c index 9989dc9..35359d5 100644 --- a/src/popen.c +++ b/src/popen.c @@ -61,6 +61,8 @@ cron_popen(char *program, const char *type, struct passwd *pw) int argc, pdes[2]; PID_T pid; char *argv[MAX_ARGS]; + ssize_t out; + char buf[PIPE_BUF]; #ifdef __GNUC__ (void) &iop; /* Avoid fork clobbering */ @@ -106,8 +108,16 @@ cron_popen(char *program, const char *type, struct passwd *pw) } (void)close(pdes[1]); } - if (execvp(argv[0], argv) < 0) - log_it("CRON", getpid(), "Mail wan't set up, some jobs could failed", strerror(errno)); + + if (execvp(argv[0], argv) < 0) { + syslog(LOG_ERR, "CRON: Exec of (%s) failed: (%s)", program, strerror(errno)); + if (*type != 'r') { + while (0 != (out = read(STDIN, buf, PIPE_BUF))) { + if ((out == -1) && (errno != EINTR)) + break; + } + } + } _exit(1); } /* parent; assume fdopen can't fail... */