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


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

Re: properly catch SIGTERM

Started byKushal Kumaran <kushal.kumaran+python@gmail.com>
First post2012-07-20 14:22 +0530
Last post2012-07-20 14:22 +0530
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: properly catch SIGTERM Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2012-07-20 14:22 +0530

#25685 — Re: properly catch SIGTERM

FromKushal Kumaran <kushal.kumaran+python@gmail.com>
Date2012-07-20 14:22 +0530
SubjectRe: properly catch SIGTERM
Message-ID<mailman.2339.1342774402.4697.python-list@python.org>
On Fri, Jul 20, 2012 at 11:39 AM, Dieter Maurer <dieter@handshake.de> wrote:
> Eric Frederich <eric.frederich@gmail.com> writes:
>> ...
>> This seems to work okay but just now I got this while hitting ctrl-c
>> It seems to have caught the signal at or in the middle of a call to
>> sys.stdout.flush()
>> --- Caught SIGTERM; Attempting to quit gracefully ---
>> Traceback (most recent call last):
>>   File "/home/user/test.py", line 125, in <module>
>>     sys.stdout.flush()
>> IOError: [Errno 4] Interrupted system call
>> How should I fix this?
>
> This is normal *nix behavior. Any signal, even if caught by a signal
> handler, can interrupt system calls.
>
> Modern *nix versions might allow to control whether a signal interrupts
> a system call or not. Check the signal documentation for your operating
> system for the control you have over signal handling. Likely,
> you cannot directly control the feature via Python, but the
> "ctypes" module allows you to call C functions directly.
>

The signal.siginterrupt function has been added in python 2.6 to do this.

-- 
regards,
kushal

[toc] | [standalone]


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


csiph-web