From f51907c4318502e326dd50013c71ead3eb589bf2 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Sat, 14 Sep 2013 10:42:34 +0200 Subject: [PATCH] RTEMS: Ensure that getopt works for subsequent spawn and finished tasks are purged. Signed-off-by: Pavel Pisa --- orte/examples/rtems-shell/orte_rtems_shell.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/orte/examples/rtems-shell/orte_rtems_shell.c b/orte/examples/rtems-shell/orte_rtems_shell.c index 6e3b252..f97be56 100644 --- a/orte/examples/rtems-shell/orte_rtems_shell.c +++ b/orte/examples/rtems-shell/orte_rtems_shell.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,9 @@ void *orte_spawn_task_func(void *arg_pack) int argc = spawn_args->argc; char **argv = &(spawn_args->argv[0]); + if (optind) + optind = 1; + if (argc) { shell_cmd = rtems_shell_lookup_cmd(argv[0]); if ( argv[1] == NULL ) { @@ -74,6 +78,8 @@ int orte_spawn_main(int argc, char **argv) spawn_args->argv[argc] = NULL; status = pthread_create(&task_id, NULL, orte_spawn_task_func, spawn_args); + if (status == 0) + pthread_detach(task_id); return status?1:0; } -- 2.39.2