Correctly wait for the MTA to finish before exiting.
authorKevin Pulo <kev@pulo.com.au>
Thu, 11 Apr 2013 11:57:55 +0000 (21:57 +1000)
committerBenjamin Mako Hill <mako@atdot.cc>
Sat, 26 Oct 2013 05:11:50 +0000 (22:11 -0700)
And use the MTA's exit code as our own (so that the various
possible error states are correctly reported to the MUA).

attachcheck

index e5ac549..e633291 100755 (executable)
@@ -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():

Benjamin Mako Hill || Want to submit a patch?