Here is the code
mutex mtx;
try{
mtx.lock();
mtx.lock();
}catch(system_error& e){
mtx.unlock();
cout << e.what() << '\n';
cout << e.code() << '\n';
}
An output device or resource busy, generic: 16
is expected but never seen.
gcc version 4.8.4
p.s.
Code above is from Bjarne Stroustrup's book -- the C++ programming language, 42.3.1.2 mutex Error. According to the book, a system_error should appear. That question about the "undefined behaviour" is posted in 2012, even before the publication of the book.