]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Add check for TID zero in support_wait_for_thread_exit
authorFlorian Weimer <fweimer@redhat.com>
Fri, 1 Oct 2021 16:16:41 +0000 (18:16 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 1 Oct 2021 16:16:41 +0000 (18:16 +0200)
Some kernel versions (observed with kernel 5.14 and earlier) can list
"0" entries in /proc/self/task.  This happens when a thread exits
while the task list is being constructed.  Treat this entry as not
present, like the proposed kernel patch does:

[PATCH] procfs: Do not list TID 0 in /proc/<pid>/task
<https://lore.kernel.org/all/8735pn5dx7.fsf@oldenburg.str.redhat.com/>

Fixes commit 032d74eaf6179100048a5bf0ce942e97dc8b9a60 ("support: Add
support_wait_for_thread_exit").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
support/support_wait_for_thread_exit.c

index 658a81381006ea6217b686c0e3f35d123082a549..5e3be421a78a4c782d5a06e94bb1a0ff07435352 100644 (file)
@@ -43,7 +43,10 @@ support_wait_for_thread_exit (void)
           return;
         }
 
-      if (strcmp (e->d_name, ".") == 0 || strcmp (e->d_name, "..") == 0)
+      /* In some kernels, "0" entries denote a thread that has just
+         exited.  */
+      if (strcmp (e->d_name, ".") == 0 || strcmp (e->d_name, "..") == 0
+          || strcmp (e->d_name, "0") == 0)
         continue;
 
       int task_tid = atoi (e->d_name);