]> projects.mako.cc - attachcheck/commitdiff
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 e5ac549ed9be819b9dcf9c54d7d57e76587b4483..e633291c10340890abf45452aac7fe3cc3da871b 100755 (executable)
@@ -58,9 +58,11 @@ def send_message():
     cmd[0] = sendmail
 
     from subprocess import Popen, PIPE
     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 )
     mailpipe.write( message_string )
-    sys.exit( mailpipe.close() )
+    mailpipe.close()
+    sys.exit( process.wait() )
 
 ## SUB: print error message
 def print_error():
 
 ## SUB: print error message
 def print_error():

Benjamin Mako Hill || Want to submit a patch?