Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: properly catch SIGTERM

21 views
Skip to first unread message

Dieter Maurer

unread,
Jul 20, 2012, 2:09:38 AM7/20/12
to pytho...@python.org
Eric Frederich <eric.fr...@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.

Kushal Kumaran

unread,
Jul 20, 2012, 4:52:59 AM7/20/12
to Dieter Maurer, pytho...@python.org
The signal.siginterrupt function has been added in python 2.6 to do this.

--
regards,
kushal
0 new messages