tests/testlib/sigpipe-worker.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 22 Sep 2022 01:50:53 +0200
changeset 49497 1baf0fffd82f
parent 48875 6000f5b25c9b
permissions -rwxr-xr-x
run-tests: display the time it took to install Mercurial It will help make people aware of this critical step and to assess the time it takes in various options (like a CI run for example).

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