-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nuttx vs posix px4_task_spawn_cmd argc and argv #12104
Comments
Thanks for the issue. This sounds familiar. I always believed that NuttX had it wrong and we needed to work around that. @LorenzMeier can you comment? |
I was under the impression that this was an expected behavior from Nuttx. Nuttx task_create adds the task name as the first argument. I thought this is why run_trampoline in ModuleBase class has the following code. But I admit, this has bothered me for some time and I had to take extra precaution in my code for arg parsing for Nuttx and posix |
Yes, we worked around non-standard behaviour in NuttX (which might have changed by now). Please also keep in mind that we're internally not storing the task name for the PX4 app classes, as the idea is that the arguments are a list of the arguments and not the POSIX interpretation of it. But it should behave the same on all platforms and it looks like it needs a closer look. Something is definitely off. |
Just to be clear: The argc and argv are consistent in both NuttX and POSIX and the same as "standard" POSIX (application name as first argument), when an application's main function is called. Just the task creation in POSIX does not fit all of the other argument lists. |
I can confirm that the behavior is different: NuttX:
Posix:
|
From what I found we would have to add:
for consistency in all |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
still a bug (even with an open pull request) |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
@julianoes Should this still be open, because you PR is also still open? |
Yes, still on my todo list 😕 |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
tl;dr:
px4_task_spawn_cmd
sets theargc
andargv
variables differently on Nuttx and Posix. Nuttx is correct and includes the command name inargv[0]
. But the Posix-Implementation only adds the arguments toargv
, which is not, what's commonly used.It's the same on macOS and Linux.
Describe the bug
I took the
hello
example application as a staring point for my application. Then I noticed, that theargc
variable is not the same on nuttx and posix inside a newly spawned task (withpx4_task_spawn_cmd
).The task is spawned like this:
When running
hello start
, nuttx will setargc
andargv
to these values inside the task:On posix on the other hand:
When running
hello start -h
, nuttx will setargc
andargv
to these values inside the task:On posix on the other hand:
To Reproduce
Steps to reproduce the behavior:
argc
andargv
variablesExpected behavior
The argument order and count would be the same on Nuttx and Posix.
The text was updated successfully, but these errors were encountered: