--- old/core/src/dird/job.cc +++ new/core/src/dird/job.cc @@ -455,7 +455,16 @@ { JobControlRecord *jcr = (JobControlRecord *)arg; - pthread_detach(pthread_self()); + /* only detach if not yet detached */ + int _detachstate; + pthread_attr_t _gattr; + pthread_getattr_np(pthread_self(), &_gattr); + pthread_attr_getdetachstate(&_gattr, &_detachstate); + pthread_attr_destroy(&_gattr); + if(_detachstate != PTHREAD_CREATE_DETACHED) { + pthread_detach(pthread_self()); + } + Dsm_check(100); Dmsg0(200, "=====Start Job=========\n"); --- old/core/src/dird/ua_server.cc +++ new/core/src/dird/ua_server.cc @@ -77,7 +77,15 @@ */ void *HandleUserAgentClientRequest(BareosSocket *user_agent_socket) { - pthread_detach(pthread_self()); + /* only detach if not yet detached */ + int _detachstate; + pthread_attr_t _gattr; + pthread_getattr_np(pthread_self(), &_gattr); + pthread_attr_getdetachstate(&_gattr, &_detachstate); + pthread_attr_destroy(&_gattr); + if(_detachstate != PTHREAD_CREATE_DETACHED) { + pthread_detach(pthread_self()); + } JobControlRecord *jcr = new_control_jcr("-Console-", JT_CONSOLE);