mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 01:53:34 +08:00
getprogname on posix: fix locking (mutex was not unlocked in some cases)
This commit is contained in:
@@ -391,16 +391,19 @@ unsigned long px4_getpid()
|
||||
const char *getprogname()
|
||||
{
|
||||
pthread_t pid = pthread_self();
|
||||
const char *prog_name = "UnknownApp";
|
||||
|
||||
pthread_mutex_lock(&task_mutex);
|
||||
|
||||
for (int i = 0; i < PX4_MAX_TASKS; i++) {
|
||||
if (taskmap[i].isused && taskmap[i].pid == pid) {
|
||||
pthread_mutex_lock(&task_mutex);
|
||||
return taskmap[i].name.c_str();
|
||||
pthread_mutex_unlock(&task_mutex);
|
||||
prog_name = taskmap[i].name.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
return "Unknown App";
|
||||
pthread_mutex_unlock(&task_mutex);
|
||||
|
||||
return prog_name;
|
||||
}
|
||||
|
||||
int px4_prctl(int option, const char *arg2, unsigned pid)
|
||||
|
||||
Reference in New Issue
Block a user