From f15c796b56930fabee4ab1ee97f7a3445fb124b9 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 1 Jul 2026 15:16:09 +1200 Subject: [PATCH] docs(nuttx): document px4_task_join limitations NuttX tasks are task_create() children, not pthreads, so px4_task_join has no portable join and instead polls whether the task still exists. Document that it returns no exit status, can wait on the wrong task if the PID is reused, and is only safe because its sole on-target caller is WorkQueueManager shutdown (and NuttX shutdown is a full reboot). Signed-off-by: Julian Oes --- platforms/nuttx/src/px4/common/tasks.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platforms/nuttx/src/px4/common/tasks.cpp b/platforms/nuttx/src/px4/common/tasks.cpp index bffb270e264..0b863c8cbbc 100644 --- a/platforms/nuttx/src/px4/common/tasks.cpp +++ b/platforms/nuttx/src/px4/common/tasks.cpp @@ -94,7 +94,12 @@ int px4_task_delete(int pid) int px4_task_join(int pid) { - // Wait for the task to exit by polling whether it still exists + // LIMITATION: NuttX tasks are task_create() children, not pthreads, so there is + // no portable join here. This waits by repeatedly checking whether the task is + // still alive. It returns no exit status, and can wait on the wrong task if the + // PID gets reused. It is only safe because the only on-target caller is + // WorkQueueManager shutdown, and NuttX shutdown is a full reboot, so this + // effectively never runs on hardware. while (kill(pid, 0) == 0) { px4_usleep(10000); }