- if (mailFd >= 0) {
- dup2(mailFd, mailf != NULL);
- dup2((mailf ? mailFd : 1), 2);
- close(mailFd);
+ if (mailFd >= 0) {
+ dup2(mailFd, mailf != NULL);
+ dup2((mailf ? mailFd : 1), 2);
+ close(mailFd);
+ }
+ execl(prog, prog, cmd, arg, NULL);
+ crondlog("\024cannot exec, user %s cmd %s %s %s\n", user, prog, cmd, arg);
+ if (mailf) {
+ fdprintf(1, "Exec failed: %s -c %s\n", prog, arg);
+ }
+ exit(0);
+ } else if (pid < 0) {
+ /* FORK FAILED */
+ crondlog("\024cannot fork, user %s\n", user);
+ line->cl_Pid = 0;
+ if (mailf) {
+ remove(mailf);
+ }
+ } else if (mailf) {
+ /* PARENT, FORK SUCCESS
+ * rename mail-file based on pid of process
+ */
+ char mailFile2[128];
+
+ snprintf(mailFile2, sizeof(mailFile2), TMPDIR "/cron.%s.%d", user, pid);
+ rename(mailf, mailFile2);