Open
Description
While running a program I got a spurious std::system_error exception.
The problem is that std::thread does very simple error handling for pthread_create:
llvm-project/libcxx/include/__thread/thread.h
Lines 257 to 258 in 96ae085
But on Linux clone system call can spuriously fail with EAGAIN:
torvalds/linux@498052b
I think std::thread should do what Go runtime does to avoid spuroius exceptions:
https://github.com/golang/go/blob/2ebe77a2fda1ee9ff6fd9a3e08933ad1ebaea039/src/runtime/cgo/gcc_libinit.c#L99-L111
Unfortunately it's not a good idea to loop infinitely since EAGAIN can be returned for other reasons (no resources, task limit reached).