(Thanks to @Therzok for filing a related issue to dotnet/runtime: dotnet/runtime#47584 )
Note the issue is different in mono/mono due to Thread.Abort and Thread.Interrupt
Description
It seems that under certain conditions, the opendir, readdir, closedir can set errno to EINTR.
The 3 syscalls are the only ones in pal_io.c that are not handling EINTR in native, but they also don't handle it in managed.
https://github.com/mono/corefx/blob/7c24bb0756fd39fbf09b8777f25c15d21d78eb46/src/Native/Unix/System.Native/pal_io.c#L468
Note: it is not documented in the man pages, but it seems to be a problem in practice.
Configuration
Mono 2020-02, macOS, x64. Not specific to this.
Regression?
Only started happening with macOS Big Sur.
Other information
See this gist for an exception being bubbled on mono which is using the same source as dotnet/runtime.