When can std :: thread :: join fail due to no_such_process

std::thread::join()resolved to crash by throwing std::system_errorfor no_such_processif the thread is "invalid." Note that the case no_such_processis different from a thread that is not connecting (for which an error code invalid_argument).

In what circumstances can this happen? Alternatively, what should I do to ensure that it is join()not suitable for this reason? I want the destructor to join()handle some threads, and, of course, I want the destructor to never throw an exception. What can make (properly constructed and not destroyed) the stream `invalid '.

+4
source share
2 answers

?

* nix , , , , (). , , .

, , , join() ?

std::thread::joinable(), 1. , . , , .


< > 1) , true false , . >

+2

no_such_process ESRCH POSIX. POSIX std::thread::join(), , pthread_join().

  • 7 POSIX ESRCH.
  • Linux pthread_join ESRCH, . ++ - , , , , this std::thread.

, , undefined, bad reinterpret_cast .

0

Source: https://habr.com/ru/post/1696362/


All Articles