Description
When stdout/stderr uses tty and has O_NONBLOCK set, the kernel driver returns -EAGAIN (https://elixir.bootlin.com/linux/v5.19/source/drivers/tty/tty_io.c#L952). This causes rust to panic, rather than try to print the same buffer again.
An example of when O_NONBLOCK is set on stdio is when using qemu serial.
I made an attempt to handle EAGAIN for std::io(#100594), but it was on generic code so not the right approach. Maybe there is a better approach to handle EAGAIN specifically for std::io and not panic?
To test this just change the stdout to O_NONBLOCK and then create 10 threads to print to stdout, C++ is able to print and finish to completion, but rust panics and crashes, so I think glibc also probably has similar support for O_NONBLOCK for stdout.
Thanks