strace/tests/redirect.test

58 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/bin/sh
#
# Ensure that strace does not retain stdin and stdout descriptors.
#
# Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
2018-12-25 02:46:43 +03:00
# Copyright (c) 2016-2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later
. "${srcdir=.}/init.sh"
run_prog_skip_if_failed \
kill -0 $$
check_prog sleep
check_prog yes
> "$OUT"
> "$LOG"
(
while [ -f "$LOG" ]; do
:
done
$SLEEP_A_BIT &
yes
if kill -0 $! 2> /dev/null; then
wait
else
echo TIMEOUT >> "$OUT"
fi
) | $STRACE -qq -enone -esignal=none \
sh -c "exec <&- >&-; rm -f -- $LOG; $SLEEP_A_BIT; $SLEEP_A_BIT"
if [ -s "$OUT" ]; then
fail_ "$STRACE failed to redirect standard input"
fi
> "$LOG"
$STRACE -qq -enone -esignal=none \
sh -c "exec <&- >&-; rm -f -- $LOG; $SLEEP_A_BIT; $SLEEP_A_BIT" |
(
while [ -f "$LOG" ]; do
:
done
$SLEEP_A_BIT &
cat > /dev/null
if kill -0 $! 2> /dev/null; then
wait
else
echo TIMEOUT >> "$OUT"
fi
)
if [ -s "$OUT" ]; then
fail_ "$STRACE failed to redirect standard output"
fi