Re: properly catch SIGTERM

Discussion in 'Python' started by Dieter Maurer, Jul 20, 2012.

  1. 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.
     
    Dieter Maurer, 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:
    662
    Rob Thorpe
    Apr 6, 2004
  2. Jane Austine
    Replies:
    2
    Views:
    1,187
    Donn Cave
    Aug 16, 2003
  3. Zoran Bosnjak

    popen3,4 and SIGTERM

    Zoran Bosnjak, Oct 15, 2003, in forum: Python
    Replies:
    0
    Views:
    425
    Zoran Bosnjak
    Oct 15, 2003
  4. Andrew Athan
    Replies:
    0
    Views:
    427
    Andrew Athan
    Jan 6, 2004
  5. Kushal Kumaran

    Re: properly catch SIGTERM

    Kushal Kumaran, Jul 20, 2012, in forum: Python
    Replies:
    0
    Views:
    168
    Kushal Kumaran
    Jul 20, 2012
Loading...

Share This Page