lkml.org 
[lkml]   [2022]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: Futex wait is not interrupted by signals if no timeout is provided
From
[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

\
 
 \ /
  Last update: 2022-08-13 03:40    [W:0.056 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site