aboutsummaryrefslogtreecommitdiff
path: root/butl/sendmail.ixx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-04-13 21:47:11 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-04-14 20:27:39 +0300
commit4408607c51a7c6e293adae41403b21d4a2c9a429 (patch)
tree9deb147c4928e6ebd5bd873779287098217d6c7e /butl/sendmail.ixx
parentabbb859d9eefa62a5cc774bd08020bf30ad77c26 (diff)
Make sendmail ctor to close pipe's reading end explicitly
Diffstat (limited to 'butl/sendmail.ixx')
-rw-r--r--butl/sendmail.ixx31
1 files changed, 17 insertions, 14 deletions
diff --git a/butl/sendmail.ixx b/butl/sendmail.ixx
index 3f6597d..2e982c1 100644
--- a/butl/sendmail.ixx
+++ b/butl/sendmail.ixx
@@ -37,22 +37,25 @@ namespace butl
const recipients_type& bcc,
O&&... options)
{
- {
- fdpipe pipe (fdopen_pipe ()); // Text mode seems appropriate.
+ fdpipe pipe (fdopen_pipe ()); // Text mode seems appropriate.
- process& p (*this);
- p = process_start (cmdc,
- pipe.in,
- 2, // No output expected so redirect to stderr.
- std::forward<E> (err),
- dir_path (),
- "sendmail",
- "-i", // Don't treat '.' as the end of input.
- "-t", // Read recipients from headers.
- std::forward<O> (options)...);
+ process& p (*this);
+ p = process_start (cmdc,
+ pipe.in,
+ 2, // No output expected so redirect to stderr.
+ std::forward<E> (err),
+ dir_path (),
+ "sendmail",
+ "-i", // Don't treat '.' as the end of input.
+ "-t", // Read recipients from headers.
+ std::forward<O> (options)...);
- out.open (std::move (pipe.out));
- } // Close pipe.in.
+ // Close the reading end of the pipe not to block on writing if sendmail
+ // terminates before that.
+ //
+ pipe.in.close ();
+
+ out.open (std::move (pipe.out));
// Write headers.
//