I am trying to debug this piece of code, where first I call fcntl
to set the stdin as non blocking, then print in a loop. With the fcntl
call, the print ultimately fails with the below error.
thread 'main' panicked at 'failed printing to stdout: Resource temporarily unavailable (os error 11)', library/std/src/io/stdio.rs:1015:9
stack backtrace:
0: rust_begin_unwind
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
2: std::io::stdio::print_to
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/stdio.rs:1015:9
3: std::io::stdio::_print
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/stdio.rs:1027:5
4: example1::main
at ./examples/example1.rs:25:9
5: core::ops::function::FnOnce::call_once
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace
I am not sure what is going on. Here are some of the things I tried.
- Tried to reproduce the issue in C, but could not.
- Use 'Nightly'. Issue can be reproduced with Nightly toolchain.
Thanks
PS:
- Part of a larger project, where FFI is required.
- Rust playground is throwing a Json error. Probably it is down, and not related to my problem.
- For some reason the said error is only seen if I redirected the stderr to a file. Without the redirection, the program will fail and exit, but no error is printed.