Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
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 984B

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