yangyalei commented on code in PR #10380:
URL: https://github.com/apache/nuttx/pull/10380#discussion_r1322913477
##########
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:
If I can change exec_spawn prototype, There is no need add the
`exec_spawn_internel` function, just delivery the spawn parameter directly to
exec_module is fine.
But the shortcomings of this way are also obvious. 1. Have to change the
definition of exec_spawn; 2. I need to change all places where exec_spawn is
called.
--
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]