On Wed, 5 Feb 2025 at 03:49, Christian Brauner <brauner@xxxxxxxxxx> wrote: > > > Btw, checking whether single-threaded this can be simplified. > It should be sufficient to do: > > stat("/proc/self/task", &st); > if ((st->st_nlink - 2) == 1) > // single threaded > > since procfs adds the number of tasks to st_nlink I'd be careful about depending on st_nlink on strange filesystems, particularly for directories. And /proc is stranger than most. So the above may happen to work, but I'm not convinced it always has had that st_nlink thing. We do it because some tools do end up looking at n_link to prune recursive directory traversal. But *most* such tools also know that st_nlink < 2 is special and might mean "don't know" (because not all filesystems actually count directory links the way traditional Unix filesystems do). So relying on /proc acting "normal" seems fragile. Linus