]> rtime.felk.cvut.cz Git - orte.git/commitdiff
RTEMS: Ensure that getopt works for subsequent spawn and finished tasks are purged.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Sat, 14 Sep 2013 08:42:34 +0000 (10:42 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Sat, 14 Sep 2013 08:42:34 +0000 (10:42 +0200)
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
orte/examples/rtems-shell/orte_rtems_shell.c

index 6e3b252205a00646ce12f97b87a6ea38d2907f55..f97be56295d2edb4870412b4c575699b95320992 100644 (file)
@@ -4,6 +4,7 @@
 #include <malloc.h>
 #include <pthread.h>
 #include <string.h>
+#include <getopt.h>
 #include <rtems/error.h>
 #include <rtems/monitor.h>
 #include <rtems/shell.h>
@@ -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;
 }