From: Kevin Pulo Date: Thu, 11 Apr 2013 11:57:55 +0000 (+1000) Subject: Correctly wait for the MTA to finish before exiting. X-Git-Url: https://projects.mako.cc/source/attachcheck/commitdiff_plain/e1c3042eba5989f7db537ceda2766e08c15f9b59?ds=sidebyside Correctly wait for the MTA to finish before exiting. And use the MTA's exit code as our own (so that the various possible error states are correctly reported to the MUA). --- diff --git a/attachcheck b/attachcheck index e5ac549..e633291 100755 --- a/attachcheck +++ b/attachcheck @@ -58,9 +58,11 @@ def send_message(): cmd[0] = sendmail from subprocess import Popen, PIPE - mailpipe = Popen(cmd, stdin=PIPE).stdin + process = Popen(cmd, stdin=PIPE) + mailpipe = process.stdin mailpipe.write( message_string ) - sys.exit( mailpipe.close() ) + mailpipe.close() + sys.exit( process.wait() ) ## SUB: print error message def print_error():