tests/testlib/sigpipe-worker.py
raw| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # This is literally `cat` but in python, one char at a time. |
| 4 | # |
| 5 | # see sigpipe-remote.py for details. |
| 6 | |
| 7 | import io |
| 8 | import os |
| 9 | import sys |
| 10 | |
| 11 | |
| 12 | if isinstance(sys.stdout.buffer, io.BufferedWriter): |
| 13 | print('SIGPIPE-WORKER: script need unbuffered output', file=sys.stderr) |
| 14 | sys.exit(255) |
| 15 | |
| 16 | while True: |
| 17 | c = os.read(sys.stdin.fileno(), 1) |
| 18 | os.write(sys.stdout.fileno(), c) |