blob: d6ab2e1ef627311323d39cbe1a3e19911849e25e [file] [log] [blame]
#!/bin/bash
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# the path as seen from the SDK
ROOT=$(dirname "$0")
# PYTHONPATH should be defined globally
# shellcheck disable=SC2154
IO="${ROOT}"/$(PYTHONPATH=${ROOT}:${PYTHONPATH} python3 -c "from common import executor_io; print(executor_io)")
mkdir -p "${IO}"
function cleanup {
rm -rf "${IO}"
}
trap cleanup EXIT
rm -f "${IO}"/output
rm -f "${IO}"/commands
mkfifo "${IO}"/output
mkfifo "${IO}"/commands
while true
do
# cat is not equivalent to < when the file is a FIFO
# shellcheck disable=SC2002
cat "${IO}"/commands | bash > "${IO}"/output
echo $? > "${IO}"/last_exit
done