blob: 8d91bbeb56d475c5122d4f164ce9587a353a6fb1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# A trap fires while a command is half parsed: the parser must resume the
# command, not carry on from a freed arena.
#
# The writer holds the pipe open and feeds `echo "a b` first. When the
# shell has started the command it writes its pid, the trap is delivered
# mid-token, and the rest arrives after the trap has run.
rm -f pid
{
echo 'trap "echo trapped" USR1'
echo 'echo $$ > pid'
printf 'echo "a b'
while [ ! -s pid ]; do sleep 0.01; done
sleep 0.3
kill -USR1 "$(cat pid)"
sleep 0.3
printf ' c" x\n'
echo 'echo done'
} | "$TSH"
|