|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
This script uses the "festival" speech synthesis app to keep saying the
word hello. Why can't I stop it with ctrl-c? Is there a workaround? #!/bin/bash while true; do echo "hello" | festival --tts done -- Dave Farrance |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
2006-08-19, 18:16(+00), Dave Farrance:
> This script uses the "festival" speech synthesis app to keep saying the > word hello. Why can't I stop it with ctrl-c? Is there a workaround? > > #!/bin/bash > while true; do > echo "hello" | festival --tts > done Yes, bash has a funny way of handling sigint. bash will only exit upon receiving a SIGINT if the current command was killed by that sigint as well (apparently). So, if "festival" ignores the sigints, it will not exit. You can try: #! /bin/bash - while :; do echo "hello" | festival --tts & wait done Then, the CTRL-C will interrup the "wait" instead of festival (which will continue running). Or: #! /bin/bash - trap 'exit 1' INT while :; do echo "hello" | festival --tts done This way, bash will still block the SIGINT but will execute its handler (exit 1) when festival finishes. -- Stéphane |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS <this.address@is.invalid> wrote:
>Yes, bash has a funny way of handling sigint. bash will only >exit upon receiving a SIGINT if the current command was killed >by that sigint as well (apparently). > >So, if "festival" ignores the sigints, it will not exit. Festival doesn't seem to ignore the ctrl-c - it will cancel the word that it's saying and the script goes on to start the next one. >You can try: > >#! /bin/bash - >while :; do > echo "hello" | festival --tts & > wait >done > >Then, the CTRL-C will interrup the "wait" instead of festival >(which will continue running). Thanks. That works. > >Or: > >#! /bin/bash - >trap 'exit 1' INT >while :; do > echo "hello" | festival --tts >done > >This way, bash will still block the SIGINT but will execute its >handler (exit 1) when festival finishes. That works too. -- Dave Farrance |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
2006-08-19, 19:30(+00), Dave Farrance:
> Stephane CHAZELAS <this.address@is.invalid> wrote: > >>Yes, bash has a funny way of handling sigint. bash will only >>exit upon receiving a SIGINT if the current command was killed >>by that sigint as well (apparently). >> >>So, if "festival" ignores the sigints, it will not exit. > > Festival doesn't seem to ignore the ctrl-c - it will cancel the word > that it's saying and the script goes on to start the next one. Then it probably intercepts the SIGINT, and the handler does a simple exit. The net result is that the exit status of festival will not show that it was terminated by a signal, so bash will not exit. I don't know why bash is behaving like that. It seems to be the only shell that does. -- Stéphane |
|
![]() |
| Outils de la discussion | |
|
|