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:
Mark Charlebois
2015-06-08 22:22:00 -07:00
parent cb231e89f6
commit 7bb70313da
3 changed files with 34 additions and 19 deletions
@@ -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()
{