Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upstd::io::Write::write should have an additional example where it handles EINTR #41219
Comments
This comment has been minimized.
This comment has been minimized.
|
Isn't SA_RESTART set by default? |
This comment has been minimized.
This comment has been minimized.
|
In general Linux, no, I don't think so. The Linux Programming Interface offers this macro (which exists in gnu libc as
If Rust set some sigactions on startup, I don't know. I wouldn't mind, actually since we could then close this and I would have learned something new. :) I think
|
Mark-Simulacrum
added
the
T-doc
label
Jun 20, 2017
This comment has been minimized.
This comment has been minimized.
|
Worth pointing out that |
Mark-Simulacrum
added
the
C-enhancement
label
Jul 27, 2017
steveklabnik
added
the
P-low
label
Aug 30, 2017
steveklabnik
added
the
E-medium
label
May 29, 2018
This comment has been minimized.
This comment has been minimized.
|
@steveklabnik @ehiggs @Mark-Simulacrum @sfackler I did a little bit of research to the
It seems to suggest that that a signal handler that does not set SA_RESTART to true, deliberately does not want the syscall to finish (like kill / hard-termination signals). Otherwise it would just set SA_RESTART to true right? Are there reasons why a signal handler would set SA_RESTART to false but would like the user to try again? It seems to be that this is quite platform specific as other platforms might handle this differently. Therefore, I think it would be better to not include this particular case as an example because it is likely to confuse less experienced programmers with details they are not likely to encounter. Based on my experience (I have never seen such an error in my years of programming), I'd say that the chances are very small that this error will actually occur. And if it does, a programmer will find out about it due to an error that will be thrown. It can then choose to handle the error accordingly, might that be desired. |
ehiggs commentedApr 11, 2017
Implementations of
std::io::Write::writethat result in a syscall can be interrupted with EINTR which means it should be tried again immediately. This is inconsistent with the existing example which uses?to bail if the call failed:Any copy-paste coders could be caught out by this.
My (bad) example: