xiaoxiang781216 commented on code in PR #10380:
URL: https://github.com/apache/nuttx/pull/10380#discussion_r1320741116


##########
binfmt/binfmt_exec.c:
##########
@@ -71,7 +155,8 @@
  *
  ****************************************************************************/
 
-int exec_spawn(FAR const char *filename, FAR char * const *argv,
+static int exec_spawn_internel(

Review Comment:
   ```suggestion
   static int exec_internel(FAR const char *filename, FAR char * const *argv,
                            FAR char * const *envp, FAR const struct symtab_s 
*exports,
                            int nexports, FAR const posix_spawn_file_actions_t 
*actions,
                            FAR const posix_spawnattr_t *attr, bool spawn)
   ```



##########
binfmt/binfmt_exec.c:
##########
@@ -141,25 +208,114 @@ int exec_spawn(FAR const char *filename, FAR char * 
const *argv,
       goto errout_with_lock;
     }
 
-#ifdef CONFIG_BINFMT_LOADABLE

Review Comment:
   revert the change



##########
binfmt/binfmt_exec.c:
##########
@@ -245,7 +401,8 @@ int exec(FAR const char *filename, FAR char * const *argv,
 {
   int ret;
 
-  ret = exec_spawn(filename, argv, envp, exports, nexports, NULL, NULL);
+  ret = exec_spawn_internel(filename, argv, envp,

Review Comment:
   ```suggestion
     ret = exec_internel(filename, argv, envp,
                         exports, nexports, NULL, NULL, false);
   ```



##########
binfmt/binfmt_exec.c:
##########
@@ -132,7 +199,7 @@ int exec_spawn(FAR const char *filename, FAR char * const 
*argv,
 
   /* Then start the module */
 
-  pid = exec_module(bin, filename, argv, envp, actions);
+  pid = exec_module(bin, filename, argv, envp, actions, false);

Review Comment:
   ```suggestion
     pid = exec_module(bin, filename, argv, envp, actions, spawn);
   ```



##########
binfmt/binfmt_exec.c:
##########
@@ -100,27 +185,9 @@ int exec_spawn(FAR const char *filename, FAR char * const 
*argv,
       goto errout_with_bin;
     }
 
-  /* Update the spawn attribute */
+  /* Update the bin spawn attribute */
 
-  if (attr)

Review Comment:
   revert the change



##########
binfmt/binfmt_exec.c:
##########
@@ -141,25 +208,114 @@ int exec_spawn(FAR const char *filename, FAR char * 
const *argv,
       goto errout_with_lock;
     }
 
-#ifdef CONFIG_BINFMT_LOADABLE
-  /* Set up to unload the module (and free the binary_s structure)
-   * when the task exists.
-   */
+  /* Release the bin memory */
 
-  ret = group_exitinfo(pid, bin);
+  ret = release_bin(bin, pid);
+
+  sched_unlock();
+  leave_critical_section(flags);
+  return pid;
+
+errout_with_lock:
+  sched_unlock();
+  leave_critical_section(flags);
+  unload_module(bin);
+errout_with_bin:
+  kmm_free(bin);
+errout:
+  return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: exec_spawn
+ *
+ * Description:
+ *   exec() configurable version, delivery the spawn attribute if this
+ *   process has special customization.
+ *
+ * Input Parameters:
+ *   filename - The path to the program to be executed. If
+ *              CONFIG_LIBC_ENVPATH is defined in the configuration, then
+ *              this may be a relative path from the current working
+ *              directory. Otherwise, path must be the absolute path to the
+ *              program.
+ *   argv     - A pointer to an array of string arguments. The end of the
+ *              array is indicated with a NULL entry.
+ *   envp     - A pointer to an array of environment strings. Terminated with
+ *              a NULL entry.
+ *   exports  - The address of the start of the caller-provided symbol
+ *              table. This symbol table contains the addresses of symbols
+ *              exported by the caller and made available for linking the
+ *              module into the system.
+ *   nexports - The number of symbols in the exports table.
+ *   actions  - The spawn file actions
+ *   attr     - The spawn attributes.
+ *
+ * Returned Value:
+ *   It returns the PID of the exec'ed module.  On failure, it returns
+ *   the negative errno value appropriately.
+ *
+ ****************************************************************************/
+
+int exec_spawn(FAR const char *filename, FAR char * const *argv,

Review Comment:
   call exec_internel directly with spawn==true



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to