[Help-bash] How send signals to coproc automatically?
From:
Peng Yu
Subject:
[Help-bash] How send signals to coproc automatically?
Date:
Mon, 12 Feb 2018 11:36:50 -0600
Hi,
The trap in the coproc can be triggered. But when I type ctrl-c to
terminate the current program. It will not be triggered. Is there a
way to let the coproc get signals from the main program? Thanks
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
trap 'echo main' EXIT
coproc {
seq 3
trap 'echo mycoproc' EXIT
}
exec 3>&"${COPROC[0]}"
sleep 1
while IFS=$'\t' read -r -u 3 line
do
printf '%s\n' "$line"
done
$ ./main.sh
1
2
3
mycoproc
$ ./main.sh
^Cmain
--
Regards,
Peng