You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

process_fds.py 945B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """Write to a handful of file descriptors, to test the childFDs= argument of
  2. reactor.spawnProcess()
  3. """
  4. from __future__ import print_function
  5. import os, sys
  6. if __name__ == "__main__":
  7. debug = 0
  8. if debug: stderr = os.fdopen(2, "w")
  9. if debug: print("this is stderr", file=stderr)
  10. abcd = os.read(0, 4)
  11. if debug: print("read(0):", abcd, file=stderr)
  12. if abcd != b"abcd":
  13. sys.exit(1)
  14. if debug: print("os.write(1, righto)", file=stderr)
  15. os.write(1, b"righto")
  16. efgh = os.read(3, 4)
  17. if debug: print("read(3):", file=stderr)
  18. if efgh != b"efgh":
  19. sys.exit(2)
  20. if debug: print("os.close(4)", file=stderr)
  21. os.close(4)
  22. eof = os.read(5, 4)
  23. if debug: print("read(5):", eof, file=stderr)
  24. if eof != b"":
  25. sys.exit(3)
  26. if debug: print("os.write(1, closed)", file=stderr)
  27. os.write(1, b"closed")
  28. if debug: print("sys.exit(0)", file=stderr)
  29. sys.exit(0)