#! /bin/bash set -e set -o pipefail cleanup() { kill -9 $(jobs -p) || true } trap cleanup EXIT python3 ./state_to_buttons.py & ( while echo $((RANDOM%2)); do if [ 0 == $((RANDOM%4)) ]; then sleep 3 fi date >&2 done ) | python3 ./stream_to_state.py