Guest User

Untitled

a guest
Oct 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. def _deliver_command(self, msg, msginfo, delivered_to, received,
  2. stdout, stderr):
  3. try:
  4. # Write out message with native EOL convention
  5. msgfile = tempfile.TemporaryFile()
  6. msgfile.write(msg.flatten(delivered_to, received,
  7. include_from=self.conf['unixfrom']))
  8. msgfile.flush()
  9. os.fsync(msgfile.fileno())
  10. # Rewind
  11. msgfile.seek(0)
  12. # Set stdin to read from this file
  13. os.dup2(msgfile.fileno(), 0)
  14. # Set stdout and stderr to write to files
  15. os.dup2(stdout.fileno(), 1)
  16. os.dup2(stderr.fileno(), 2)
  17.  
  18. os.dup2(stdout.fileno(), 1)
Add Comment
Please, Sign In to add comment