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


##########
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:
   add a new spawn param?  I wrote it like this at first, but you suggested add 
a new function instead of modifying the definition of exec_spawn.
   `let's add an internal function to avoid change exec_spawn prototype`



-- 
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