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_tester.py 779B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """Test program for processes."""
  2. import os
  3. import sys
  4. test_file_match = "process_test.log.*"
  5. test_file = "process_test.log.%d" % os.getpid()
  6. def main():
  7. f = open(test_file, "wb")
  8. stdin = sys.stdin.buffer
  9. stderr = sys.stderr.buffer
  10. stdout = sys.stdout.buffer
  11. # stage 1
  12. b = stdin.read(4)
  13. f.write(b"one: " + b + b"\n")
  14. # stage 2
  15. stdout.write(b)
  16. stdout.flush()
  17. os.close(sys.stdout.fileno())
  18. # and a one, and a two, and a...
  19. b = stdin.read(4)
  20. f.write(b"two: " + b + b"\n")
  21. # stage 3
  22. stderr.write(b)
  23. stderr.flush()
  24. os.close(stderr.fileno())
  25. # stage 4
  26. b = stdin.read(4)
  27. f.write(b"three: " + b + b"\n")
  28. # exit with status code 23
  29. sys.exit(23)
  30. if __name__ == "__main__":
  31. main()