[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
trap EXIT in piped subshell not triggered during wait
From: |
Ilya Basin |
Subject: |
trap EXIT in piped subshell not triggered during wait |
Date: |
Sat, 13 Apr 2013 09:35:10 +0400 |
Hi!
I've got strange behavior. Here's my script:
#!/bin/bash
{
trap '
echo "in trap EXIT">&2
' EXIT
sleep 4 &
echo 'sleep 2'>&2
sleep 2
echo 'wait $!'>&2
wait $!
echo 'exit'>&2
exit
} | cat
If I press Ctrl-C during wait, the trap isn't triggered.
If I replace curly brackets with round brackets, it works. What's the
difference?
- trap EXIT in piped subshell not triggered during wait,
Ilya Basin <=