[Yum] Re: Horrible response to keyboardInterrupt

James Antill james-yum at and.org
Sun Sep 14 04:31:48 UTC 2008


Seth Vidal <skvidal at fedoraproject.org> writes:

> On Thu, 2008-09-11 at 19:32 -0700, CAI Qian wrote:
>
>> Correct. That is one of situations of bad CTRL-C response. I was trying
>> to simulate a network failure or slow connection. It could be quite
>> normal in reality.
>> 
>
> Great, then please file this  against python.
>
> $ ipython
> In [1]: import socket
>
> In [4]: socket.gethostbyname('www.phy.duke.edu')
> ^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C---------------------------------------------------------------------------
> KeyboardInterrupt                         Traceback (most recent call
> last)
>
> the socket call to gethostbyname does let you do an interrupt in the
> middle of it - or at least - not at all times.

 Or don't :).

 Unless you can make the above work for C, bearing in mind:

1. gethostbyname¹ is "magic" and lives inside libc.

2. A C-c/kill(SIGINT) is sent to a process via. calling whatever
function is the SIG_INT function.

3. The "default" behaviour of the SIG_INT function is just to
immediately exit.

4. You can't do much more than #3 within a signal handler, because you
don't know what code you are running.

5. #3 is unacceptable for pretty much any half decent program², and
given #4 the only option is to communicate to the rest of the program
within the signal handler. The rest of the code then periodically
checks for this communication.

6. Due to #1 and #5, gethostbyname/etc. cannot be interrupted
within any half decent program.

 The only available solutions are:

1. Run all resolving code in another process, which just does that
(lots of code, and annoying as hell ... and all the code needs to call
this special resolving code).

2. Fix libc to have an "official" way to communicate the C-c to libc.

...don't hold your breath on #1, and good luck with #2.


¹ Actually getaddrinfo, but meh.

² Some apps. may not qualify as half decent by this measure, but
meh. ... as they probably aren't ;)

-- 
James Antill -- james at and.org



More information about the Yum mailing list