From 4408607c51a7c6e293adae41403b21d4a2c9a429 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 13 Apr 2017 21:47:11 +0300 Subject: Make sendmail ctor to close pipe's reading end explicitly --- butl/sendmail.ixx | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'butl/sendmail.ixx') 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 (err), - dir_path (), - "sendmail", - "-i", // Don't treat '.' as the end of input. - "-t", // Read recipients from headers. - std::forward (options)...); + process& p (*this); + p = process_start (cmdc, + pipe.in, + 2, // No output expected so redirect to stderr. + std::forward (err), + dir_path (), + "sendmail", + "-i", // Don't treat '.' as the end of input. + "-t", // Read recipients from headers. + std::forward (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. // -- cgit v1.1