Fixing some bugs in 'mail', with fixes reported by Sergio Ballestrero.
authorviric@vicerveza
Tue, 12 Aug 2008 12:50:43 +0200
changeset 238 d490cad20a00
parent 237 ee56196997ed
child 239 18301d7a56d4
Fixing some bugs in 'mail', with fixes reported by Sergio Ballestrero.
mail.c
--- a/mail.c	Mon Aug 11 22:17:02 2008 +0200
+++ b/mail.c	Tue Aug 12 12:50:43 2008 +0200
@@ -33,13 +33,14 @@
             close(0);
             close(1);
             close(2);
+	    close(p[1]);
             dup2(p[0], 0);
             execl("/usr/sbin/sendmail", "sendmail", "-oi", dest, NULL);
             error("run sendmail");
         case -1:
             error("fork sendmail");
         default: /* Parent */
-            ;
+	    close(p[0]);
     }
     return p[1];
 }
@@ -116,6 +117,7 @@
     char *user;
     char *env_to;
     int write_fd;
+    int status;
 
     env_to = getenv("TS_MAILTO");
 
@@ -134,4 +136,5 @@
     write_header(write_fd, to, command, jobid, errorlevel);
     copy_output(write_fd, ofname);
     close(write_fd);
+    wait(&status);
 }