tests/testlib/sigpipe-worker.py
author Anton Shestakov <av6@dwimlabs.net>
Thu, 05 Oct 2023 14:47:42 -0300
branchstable
changeset 50990 758e40b9a8af
parent 48875 6000f5b25c9b
permissions -rwxr-xr-x
httppeer: fix static-http: scheme autodetection (issue6833) Since statichttprepo.make_peer() assumes path is a urlutil.path object (by accessing path.loc), we no longer can just provide a bytestring there. See also 5f71fff8dc74 and cfe8d88a453e.

#!/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)