Bugfix:pthread_create retuns 0 on success and positive error on error without errono set

This commit is contained in:
David Sidrane 2015-09-23 06:17:14 -10:00
parent a5ad7641e3
commit 05a08252ff
1 changed files with 4 additions and 3 deletions

View File

@ -98,6 +98,7 @@ UavcanServers::~UavcanServers()
if (_mutex_inited) {
(void)Lock::deinit(_subnode_mutex);
}
_main_node.getDispatcher().removeRxFrameListener();
}
@ -164,9 +165,9 @@ int UavcanServers::start(uavcan::INode &main_node)
rv = pthread_create(&_instance->_subnode_thread, &tattr, static_cast<pthread_startroutine_t>(run_trampoline), NULL);
if (rv < 0) {
warnx("pthread_create() failed: %d", errno);
rv = -errno;
if (rv != 0) {
rv = -rv;
warnx("pthread_create() failed: %d", rv);
delete _instance;
_instance = nullptr;
}