mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 05:53:33 +08:00
POSIX: use px4_getpid()
The posix build only has one process so calling getpid() will not provide the expected result. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -273,6 +273,21 @@ void px4_show_tasks()
|
||||
}
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int px4_getpid()
|
||||
{
|
||||
pthread_t pid = pthread_self();
|
||||
|
||||
// Get pthread ID from the opaque ID
|
||||
for (int i=0; i<PX4_MAX_TASKS; ++i) {
|
||||
if (taskmap[i].pid == pid) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
PX4_ERR("px4_getpid() called from non-thread context!");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
const char *getprogname();
|
||||
const char *getprogname()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user