[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] audit needed for signal handlers
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] audit needed for signal handlers |
Date: |
Mon, 11 Nov 2013 18:05:51 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9 |
Il 11/11/2013 17:56, Anthony Liguori ha scritto:
> On Mon, Nov 11, 2013 at 8:50 AM, Eric Blake <address@hidden> wrote:
>> Quick - identify the bug in this code (from ui/curses.c):
>>
>> static void curses_winch_handler(int signum)
>> {
>> struct winsize {
>> unsigned short ws_row;
>> unsigned short ws_col;
>> unsigned short ws_xpixel; /* unused */
>> unsigned short ws_ypixel; /* unused */
>> } ws;
>>
>> /* terminal size changed */
>> if (ioctl(1, TIOCGWINSZ, &ws) == -1)
>> return;
>>
>> resize_term(ws.ws_row, ws.ws_col);
>> curses_calc_pad();
>> invalidate = 1;
>>
>> /* some systems require this */
>> signal(SIGWINCH, curses_winch_handler);
>> }
>>
>> Here's a hint: ioctl() can clobber errno. But if a signal handler is
>> called in the middle of other code that is using errno, then the handler
>> MUST restore the value of errno before returning, if it is to guarantee
>> that the interrupted context won't be corrupted.
>
> Isn't this precisely why EINTR exists?
No.
do {
rc = read(...);
} while (rc == -1 && errno == EINTR);
/* signal handler runs here */
if (errno == EAGAIN) {
...
}
That said, aren't all signals in QEMU (except SIG_IPI) caught with
signalfd and the handlers run synchronously in the iothread?
Paolo
- [Qemu-devel] audit needed for signal handlers, Eric Blake, 2013/11/11
- Re: [Qemu-devel] audit needed for signal handlers, Anthony Liguori, 2013/11/11
- Re: [Qemu-devel] audit needed for signal handlers, Eric Blake, 2013/11/11
- Re: [Qemu-devel] audit needed for signal handlers,
Paolo Bonzini <=
- Re: [Qemu-devel] audit needed for signal handlers, Peter Maydell, 2013/11/11
- Re: [Qemu-devel] audit needed for signal handlers, Eric Blake, 2013/11/11
- Re: [Qemu-devel] audit needed for signal handlers, Paolo Bonzini, 2013/11/11
- Re: [Qemu-devel] audit needed for signal handlers, Gerd Hoffmann, 2013/11/12
- Re: [Qemu-devel] audit needed for signal handlers, Laszlo Ersek, 2013/11/12
- Re: [Qemu-devel] audit needed for signal handlers, Eric Blake, 2013/11/11
- Re: [Qemu-devel] audit needed for signal handlers, Paolo Bonzini, 2013/11/11
Re: [Qemu-devel] audit needed for signal handlers, Peter Maydell, 2013/11/11
Re: [Qemu-devel] audit needed for signal handlers, Max Filippov, 2013/11/11