Changeset View
Changeset View
Standalone View
Standalone View
bin/sh/tests/builtins/read11.0
- This file was added.
set -e | |||||
T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) | |||||
trap 'rm -rf "$T"' 0 | |||||
jilles: Existing tests use `mktemp -d`, placing the fifo into a temporary directory, to avoid the… | |||||
cd $T | |||||
mkfifo fifo1 | |||||
# Open fifo1 for writing and then read block on a dummy fifo | |||||
Not Done Inline ActionsHmm, how portable is this? It is probably faster than forking off a child process to open the fifo for writing, which the standard requires and other tests do. jilles: Hmm, how portable is this? It is probably faster than forking off a child process to open the… | |||||
{ mkfifo fifo2; read dummy <fifo2; } >fifo1 & | |||||
# Wait for the child to open fifo1 for writing | |||||
exec 3<fifo1 | |||||
v=original_value | |||||
Done Inline ActionsSome other tests do stuff like [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = TERM ] to avoid depending on signal numbers. jilles: Some other tests do stuff like `[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = TERM ]` to avoid… | |||||
r=0 | |||||
read -t 0 v <&3 || r=$? | |||||
kill -TERM "$!" || : | |||||
{ [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = ALRM ]; } || exit | |||||
[ -z "$v" ] |
Existing tests use mktemp -d, placing the fifo into a temporary directory, to avoid the discouraged -u option.