]> granicus.if.org Git - cronie/commitdiff
Some cron jobs failed without error message. If the job had
authorMarcela Maslanova <marca@dhcp-lab-135.englab.brq.redhat.com>
Mon, 29 Oct 2007 15:00:57 +0000 (16:00 +0100)
committerMarcela Maslanova <marca@dhcp-lab-135.englab.brq.redhat.com>
Mon, 29 Oct 2007 15:00:57 +0000 (16:00 +0100)
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

src/popen.c

index 9989dc981b025252c45199a195316dbfd8909a69..35359d5771a6b0637f6ecf2d030d9f63a2f086a9 100644 (file)
@@ -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...  */