Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: properly catch SIGTERM

Reply
Thread Tools

Re: properly catch SIGTERM

 
 
Kushal Kumaran
Guest
Posts: n/a
 
      07-20-2012
On Fri, Jul 20, 2012 at 11:39 AM, Dieter Maurer <(E-Mail Removed)> wrote:
> Eric Frederich <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: properly catch SIGTERM Dieter Maurer Python 0 07-20-2012 06:09 AM
Child process does not exit after receiving SIGTERM Teresa C Programming 2 04-06-2004 01:26 AM
Repost: Can't sys.exit() from SIGTERM handler? Andrew Athan Python 0 01-06-2004 01:27 AM
popen3,4 and SIGTERM Zoran Bosnjak Python 0 10-15-2003 03:01 PM
robust clean-up with SIGTERM (was Re: Again, how to write a cleanup function for a module in C ) Jane Austine Python 2 08-16-2003 04:01 AM



Advertisments