tests/testlib/sigpipe-worker.py
author Gregory Szorc <gregory.szorc@gmail.com>
Thu, 03 Mar 2022 17:34:00 +0100
changeset 48875 6000f5b25c9b
parent 47618 27ff81547d35
permissions -rwxr-xr-x
py2: remove simple from __future__ statements These were needed for Python 2 support. Now that our linter no longer mandates these, we can start deleting them. Differential Revision: https://phab.mercurial-scm.org/D12254

#!/usr/bin/env python3
#
# This is literally `cat` but in python, one char at a time.
#
# see sigpipe-remote.py for details.

import io
import os
import sys


if isinstance(sys.stdout.buffer, io.BufferedWriter):
    print('SIGPIPE-WORKER: script need unbuffered output', file=sys.stderr)
    sys.exit(255)

while True:
    c = os.read(sys.stdin.fileno(), 1)
    os.write(sys.stdout.fileno(), c)