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


Groups > comp.lang.python > #50894

KeyboardInterrupt in Subproccesses

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <mclefavor@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.099
X-Spam-Evidence '*H*': 0.80; '*S*': 0.00; 'raises': 0.09; 'wrapper': 0.09; 'python': 0.11; 'missing?': 0.16; 'points:': 0.16; '(not': 0.18; "python's": 0.19; 'bonus': 0.22; 'all:': 0.24; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'raised': 0.31; 'maintaining': 0.32; 'run': 0.32; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'raising': 0.36; 'skip:& 10': 0.38; 'process,': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'obtain': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'close': 0.67; 'press': 0.70; 'behavior': 0.77; 'case?': 0.84; 'subject:skip:S 10': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=RlwNAqp9DDilgeeovdh+fvCgRFfJdAzkCJsz0BdOrx8=; b=C7XM8k+Tzb4NUURyhurkWBxO/+E8eAzQMdLWn3KsJwyUatmse/mTORIadnrKlVqHIm n99kr4iTUS+m9B45gC3kldGAyOGjnMup5cqGuI66KCwtK+9ARXvC++emXrvNyRVao9SR M9UbckuH2VTE1PXEo1jVUth6yxJxNRtwt7BEa9rDG9htEApYPoo4Vd+mSDM/DW7lB7T9 MF74TyZQTLEdE4aKLuqwlmzG0hwk3bHbIGRtXIldpy1F3LQhnKPykSXS9Qy5vdmPP4k9 oeVPshw33F3dUSVCkhvHwvdva9I7r03y8x9hcj/bZEttlKiSFE28Ekp6F30MpMwy5ksM rh7g==
X-Received by 10.43.51.68 with SMTP id vh4mr7021444icb.52.1374173116944; Thu, 18 Jul 2013 11:45:16 -0700 (PDT)
MIME-Version 1.0
From Matthew Lefavor <mclefavor@gmail.com>
Date Thu, 18 Jul 2013 14:44:36 -0400
Subject KeyboardInterrupt in Subproccesses
To python-list@python.org
Content-Type multipart/alternative; boundary=bcaec529a0fb7ed6c404e1cd9c99
X-Mailman-Approved-At Fri, 19 Jul 2013 09:50:32 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4860.1374220233.3114.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1374220233 news.xs4all.nl 15928 [2001:888:2000:d::a6]:49790
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50894

Show key headers only | View raw


[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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web