Re: properly catch SIGTERM

Discussion in 'Python' started by Kushal Kumaran, Jul 20, 2012.

  1. On Fri, Jul 20, 2012 at 11:39 AM, Dieter Maurer <> wrote:
    > Eric Frederich <> 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
    Kushal Kumaran, Jul 20, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Teresa
    Replies:
    2
    Views:
    646
    Rob Thorpe
    Apr 6, 2004
  2. Jane Austine
    Replies:
    2
    Views:
    1,117
    Donn Cave
    Aug 16, 2003
  3. Zoran Bosnjak

    popen3,4 and SIGTERM

    Zoran Bosnjak, Oct 15, 2003, in forum: Python
    Replies:
    0
    Views:
    405
    Zoran Bosnjak
    Oct 15, 2003
  4. Andrew Athan
    Replies:
    0
    Views:
    410
    Andrew Athan
    Jan 6, 2004
  5. Dieter Maurer

    Re: properly catch SIGTERM

    Dieter Maurer, Jul 20, 2012, in forum: Python
    Replies:
    0
    Views:
    191
    Dieter Maurer
    Jul 20, 2012
Loading...

Share This Page