Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50894 > unrolled thread

KeyboardInterrupt in Subproccesses

Started byMatthew Lefavor <mclefavor@gmail.com>
First post2013-07-18 14:44 -0400
Last post2013-07-18 14:44 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  KeyboardInterrupt in Subproccesses Matthew Lefavor <mclefavor@gmail.com> - 2013-07-18 14:44 -0400

#50894 — KeyboardInterrupt in Subproccesses

FromMatthew Lefavor <mclefavor@gmail.com>
Date2013-07-18 14:44 -0400
SubjectKeyboardInterrupt in Subproccesses
Message-ID<mailman.4860.1374220233.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

All:

I am maintaining a program in Python 2 and need to send it a
KeyboardInterrupt to close it. Unfortunately, the program is used as a
subprocess in a wrapper subprocess, and so I cannot just directly press
CTL-C; I have to use a signal.

When I run the program "bare" (not in a subprocess), I have found that
raising a SIGINT (kill -2) raises a KeyboardInterrupt in the program. But
when I run the program in the wrapper process, kill -2 no longer has any
effect (whether it is raised by the wrapper or externally).

Why is that the case? Does Python's interpretation of SIGINT as a
KeyboardInterrupt only obtain when the program is run in a terminal? Is
there something else I'm missing?

Bonus points: Is this behavior the same for Python 3?

MCL

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web