samedi 29 mars 2014

Why does cancelling a pthread in an IO function of istream / ostream set the badbit?


Vote count:

0




I was looking into libstdc++ code and was surprised that it sets the badbit on a stream when an operator>> or operator<< is interupted by a cancellation point of pthread (which, if I understand correctly, is implemented by throwing a special magic exception object).


Apparently, the C++ Standard requires that an exception escaping to the respective I/O function shall set the badbit. But to my understanding, a pthread cancellation isn't needed to be considered an "exception" in the C++ sense.


Does that mean that when calling pthread_cancel'ing a thread that uses cout and friends, one always has to clear the badbit after the thread doing the I/O exited (to be sure just in case the thread caused the badbit to be set)?



asked 57 secs ago






Aucun commentaire:

Enregistrer un commentaire