[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <19555696-0bb3-f1f4-2c4d-4d3334f49212@infradead.org>
Date: Fri, 12 Aug 2022 18:38:57 -0700
From: Randy Dunlap <rdunlap@...radead.org>
To: Elijah Stone <elronnd-linux@...onnd.net>,
linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>
Subject: Re: Futex wait is not interrupted by signals if no timeout is
provided
[add tglx and mingo]
On 8/12/22 18:14, Elijah Stone wrote:
> I've observed a strange behaviour of futexes that I believe to be a bug. If a signal is delivered while a futex wait is in progress, the wait will be interrupted, but only if that wait had a timeout. I expect it to be interrupted regardless of whether a timeout is provided. The following runnable snippet demonstrates this:
>
> void handler(int) { printf("SIGINT\n"); }
> int main() {
> signal(SIGINT,handler);
> int i=2;
> printf("1\n");
> syscall(SYS_futex, &i, FUTEX_WAIT, 2, &(struct timespec){.tv_sec=1000});
> printf("2\n");
> syscall(SYS_futex, &i, FUTEX_WAIT, 2, NULL);
> printf("3\n");
> }
>
> Pressing ^C once causes the first wait to terminate, and '2' to be printed. But repeatedly pressing it after that does not allow the program to make progress.
--
~Randy
Powered by blists - more mailing lists