How to return from SystemC thread with error code?
The answer, of course, is to have sc_main get its return value by reaching directly into the module that it instantiates to get at a member variable:

return(test_module.exit_code);


I need to remember that we're still running C++ and basic C++ rules apply, so this is possible.  In my hardware-design mind, I was spinning off modules and threads that had no connection to the classes that they actually are.