Ctrl-C forwarded to command executed via popen on Unix
Kragen Sitaker
kragen at pobox.com
Thu May 23 14:27:16 EDT 2002
Eric Brunel <eric.brunel at pragmadev.com> writes:
> We've just noticed a very strange problem regarding the use of the
> Ctrl-C key in the Python interpreter when a command is being run
> through a pipe on Unix: the interpreter gets it, raising a
> KeyboardInterrupt exception as it should, but the running command
> also seems to get the interrupt! ... Is it a feature or a bug? If
> it's a feature, what is the reason behind it?
^C sends SIGINT to the tty pgrp; processes you fork stay in your pgrp
unless they setpgrp() or setpgid(). This way a ^C on ls | sort | uniq
| wc kills all four programs immediately, not just one of them.
Perhaps popen should cause the child process to ignore SIGINT?
More information about the Python-list
mailing list