when setting up pipes in child process check for case where stdin == pipe fd 0
This commit is contained in:
@@ -469,10 +469,12 @@ send_mail(line)
|
|||||||
char *mpath, *mflags;
|
char *mpath, *mflags;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Child. */
|
/* Child, set stdin to output side of the pipe */
|
||||||
(void) close(pfd[1]);
|
if (pfd[0] != STDIN_FILENO) {
|
||||||
(void) dup2(pfd[0], STDIN_FILENO);
|
(void) dup2(pfd[0], STDIN_FILENO);
|
||||||
(void) close(pfd[0]);
|
(void) close(pfd[0]);
|
||||||
|
}
|
||||||
|
(void) close(pfd[1]);
|
||||||
|
|
||||||
/* Build up an argv based the mailer path and flags */
|
/* Build up an argv based the mailer path and flags */
|
||||||
mflags = estrdup(def_str(I_MAILERFLAGS));
|
mflags = estrdup(def_str(I_MAILERFLAGS));
|
||||||
@@ -501,8 +503,8 @@ send_mail(line)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mail = fdopen(pfd[1], "w");
|
|
||||||
(void) close(pfd[0]);
|
(void) close(pfd[0]);
|
||||||
|
mail = fdopen(pfd[1], "w");
|
||||||
|
|
||||||
/* Pipes are all setup, send message via sendmail. */
|
/* Pipes are all setup, send message via sendmail. */
|
||||||
(void) fprintf(mail, "To: %s\nFrom: %s\nSubject: ",
|
(void) fprintf(mail, "To: %s\nFrom: %s\nSubject: ",
|
||||||
|
Reference in New Issue
Block a user