view tests/testlib/sigpipe-worker.py @ 48281:8f54d9c79b12

dirstate: add missing return on platforms without exec or symlink Differential Revision: https://phab.mercurial-scm.org/D11713
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 20 Oct 2021 18:40:03 +0200
parents 27ff81547d35
children 6000f5b25c9b
line wrap: on
line source

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

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)