mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
Revert "sched/posix_spawn: Don't insert name at the begin of argv"
This reverts commit 032086870d.
This commit is contained in:
@@ -168,7 +168,7 @@ int exec_module(FAR const struct binary_s *binp,
|
|||||||
|
|
||||||
/* Initialize the task */
|
/* Initialize the task */
|
||||||
|
|
||||||
ret = nxtask_init(tcb, false, filename, binp->priority,
|
ret = nxtask_init(tcb, filename, binp->priority,
|
||||||
NULL, binp->stacksize, binp->entrypt, argv);
|
NULL, binp->stacksize, binp->entrypt, argv);
|
||||||
binfmt_freeargv(argv);
|
binfmt_freeargv(argv);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
@@ -909,8 +909,7 @@ FAR struct streamlist *nxsched_get_streams(void);
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* tcb - Address of the new task's TCB
|
* tcb - Address of the new task's TCB
|
||||||
* insert_name - Insert name to the first argv
|
* name - Name of the new task (not used)
|
||||||
* name - Name of the new task
|
|
||||||
* priority - Priority of the new task
|
* priority - Priority of the new task
|
||||||
* stack - Start of the pre-allocated stack
|
* stack - Start of the pre-allocated stack
|
||||||
* stack_size - Size (in bytes) of the stack allocated
|
* stack_size - Size (in bytes) of the stack allocated
|
||||||
@@ -928,8 +927,7 @@ FAR struct streamlist *nxsched_get_streams(void);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nxtask_init(FAR struct task_tcb_s *tcb, bool insert_name,
|
int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
|
||||||
const char *name, int priority,
|
|
||||||
FAR void *stack, uint32_t stack_size, main_t entry,
|
FAR void *stack, uint32_t stack_size, main_t entry,
|
||||||
FAR char * const argv[]);
|
FAR char * const argv[]);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -44,8 +44,8 @@ struct tcb_s; /* Forward reference */
|
|||||||
void nxtask_start(void);
|
void nxtask_start(void);
|
||||||
int nxtask_setup_scheduler(FAR struct task_tcb_s *tcb, int priority,
|
int nxtask_setup_scheduler(FAR struct task_tcb_s *tcb, int priority,
|
||||||
start_t start, main_t main, uint8_t ttype);
|
start_t start, main_t main, uint8_t ttype);
|
||||||
int nxtask_setup_arguments(FAR struct task_tcb_s *tcb, bool insert_name,
|
int nxtask_setup_arguments(FAR struct task_tcb_s *tcb, FAR const char *name,
|
||||||
FAR const char *name, FAR char * const argv[]);
|
FAR char * const argv[]);
|
||||||
|
|
||||||
/* Task exit */
|
/* Task exit */
|
||||||
|
|
||||||
|
|||||||
@@ -91,8 +91,7 @@ static int nxthread_create(FAR const char *name, uint8_t ttype,
|
|||||||
|
|
||||||
/* Initialize the task */
|
/* Initialize the task */
|
||||||
|
|
||||||
ret = nxtask_init(tcb, true, name, priority,
|
ret = nxtask_init(tcb, name, priority, NULL, stack_size, entry, argv);
|
||||||
NULL, stack_size, entry, argv);
|
|
||||||
if (ret < OK)
|
if (ret < OK)
|
||||||
{
|
{
|
||||||
kmm_free(tcb);
|
kmm_free(tcb);
|
||||||
|
|||||||
@@ -63,8 +63,7 @@
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* tcb - Address of the new task's TCB
|
* tcb - Address of the new task's TCB
|
||||||
* insert_name - Insert name to the first argv
|
* name - Name of the new task (not used)
|
||||||
* name - Name of the new task
|
|
||||||
* priority - Priority of the new task
|
* priority - Priority of the new task
|
||||||
* stack - Start of the pre-allocated stack
|
* stack - Start of the pre-allocated stack
|
||||||
* stack_size - Size (in bytes) of the stack allocated
|
* stack_size - Size (in bytes) of the stack allocated
|
||||||
@@ -82,8 +81,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nxtask_init(FAR struct task_tcb_s *tcb, bool insert_name,
|
int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
|
||||||
const char *name, int priority,
|
|
||||||
FAR void *stack, uint32_t stack_size,
|
FAR void *stack, uint32_t stack_size,
|
||||||
main_t entry, FAR char * const argv[])
|
main_t entry, FAR char * const argv[])
|
||||||
{
|
{
|
||||||
@@ -155,7 +153,7 @@ int nxtask_init(FAR struct task_tcb_s *tcb, bool insert_name,
|
|||||||
|
|
||||||
/* Setup to pass parameters to the new task */
|
/* Setup to pass parameters to the new task */
|
||||||
|
|
||||||
nxtask_setup_arguments(tcb, insert_name, name, argv);
|
nxtask_setup_arguments(tcb, name, argv);
|
||||||
|
|
||||||
/* Now we have enough in place that we can join the group */
|
/* Now we have enough in place that we can join the group */
|
||||||
|
|
||||||
|
|||||||
+34
-40
@@ -452,6 +452,13 @@ static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, int priority,
|
|||||||
static void nxtask_setup_name(FAR struct task_tcb_s *tcb,
|
static void nxtask_setup_name(FAR struct task_tcb_s *tcb,
|
||||||
FAR const char *name)
|
FAR const char *name)
|
||||||
{
|
{
|
||||||
|
/* Give a name to the unnamed tasks */
|
||||||
|
|
||||||
|
if (!name)
|
||||||
|
{
|
||||||
|
name = (FAR char *)g_noname;
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy the name into the TCB */
|
/* Copy the name into the TCB */
|
||||||
|
|
||||||
strncpy(tcb->cmn.name, name, CONFIG_TASK_NAME_SIZE);
|
strncpy(tcb->cmn.name, name, CONFIG_TASK_NAME_SIZE);
|
||||||
@@ -473,22 +480,20 @@ static void nxtask_setup_name(FAR struct task_tcb_s *tcb,
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* tcb - Address of the new task's TCB
|
* tcb - Address of the new task's TCB
|
||||||
* insert_name - Insert name to the first entry
|
* argv - A pointer to an array of input parameters. The arrau should be
|
||||||
* name - Name of the new task
|
* terminated with a NULL argv[] value. If no parameters are
|
||||||
* argv - A pointer to an array of input parameters. The array
|
* required, argv may be NULL.
|
||||||
* should be terminated with a NULL argv[] value. If no
|
|
||||||
* parameters are required, argv may be NULL.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero (OK) on success; a negated errno on failure.
|
* Zero (OK) on success; a negated errno on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static inline int
|
static inline int nxtask_setup_stackargs(FAR struct task_tcb_s *tcb,
|
||||||
nxtask_setup_stackargs(FAR struct task_tcb_s *tcb, bool insert_name,
|
FAR char * const argv[])
|
||||||
FAR const char *name, FAR char * const argv[])
|
|
||||||
{
|
{
|
||||||
FAR char **stackargv;
|
FAR char **stackargv;
|
||||||
|
FAR const char *name;
|
||||||
FAR char *str;
|
FAR char *str;
|
||||||
size_t strtablen;
|
size_t strtablen;
|
||||||
size_t argvlen;
|
size_t argvlen;
|
||||||
@@ -496,9 +501,17 @@ nxtask_setup_stackargs(FAR struct task_tcb_s *tcb, bool insert_name,
|
|||||||
int argc;
|
int argc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* Get the name string that we will use as the first argument */
|
||||||
|
|
||||||
|
#if CONFIG_TASK_NAME_SIZE > 0
|
||||||
|
name = tcb->cmn.name;
|
||||||
|
#else
|
||||||
|
name = (FAR const char *)g_noname;
|
||||||
|
#endif /* CONFIG_TASK_NAME_SIZE */
|
||||||
|
|
||||||
/* Get the size of the task name (including the NUL terminator) */
|
/* Get the size of the task name (including the NUL terminator) */
|
||||||
|
|
||||||
strtablen = insert_name ? (strlen(name) + 1) : 0;
|
strtablen = (strlen(name) + 1);
|
||||||
|
|
||||||
/* Count the number of arguments and get the accumulated size of the
|
/* Count the number of arguments and get the accumulated size of the
|
||||||
* argument strings (including the null terminators). The argument count
|
* argument strings (including the null terminators). The argument count
|
||||||
@@ -541,7 +554,7 @@ nxtask_setup_stackargs(FAR struct task_tcb_s *tcb, bool insert_name,
|
|||||||
* task name plus a NULL argv[] entry to terminate the list.
|
* task name plus a NULL argv[] entry to terminate the list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
argvlen = (insert_name + argc + 1) * sizeof(FAR char *);
|
argvlen = (argc + 2) * sizeof(FAR char *);
|
||||||
stackargv = (FAR char **)up_stack_frame(&tcb->cmn, argvlen + strtablen);
|
stackargv = (FAR char **)up_stack_frame(&tcb->cmn, argvlen + strtablen);
|
||||||
|
|
||||||
DEBUGASSERT(stackargv != NULL);
|
DEBUGASSERT(stackargv != NULL);
|
||||||
@@ -550,8 +563,6 @@ nxtask_setup_stackargs(FAR struct task_tcb_s *tcb, bool insert_name,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcb->argv = stackargv;
|
|
||||||
|
|
||||||
/* Get the address of the string table that will lie immediately after
|
/* Get the address of the string table that will lie immediately after
|
||||||
* the argv[] array and mark it as a null string.
|
* the argv[] array and mark it as a null string.
|
||||||
*/
|
*/
|
||||||
@@ -562,13 +573,10 @@ nxtask_setup_stackargs(FAR struct task_tcb_s *tcb, bool insert_name,
|
|||||||
* NUL terminator in the string buffer.
|
* NUL terminator in the string buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (insert_name)
|
stackargv[0] = str;
|
||||||
{
|
|
||||||
*stackargv++ = str;
|
|
||||||
nbytes = strlen(name) + 1;
|
nbytes = strlen(name) + 1;
|
||||||
strcpy(str, name);
|
strcpy(str, name);
|
||||||
str += nbytes;
|
str += nbytes;
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy each argument */
|
/* Copy each argument */
|
||||||
|
|
||||||
@@ -579,7 +587,7 @@ nxtask_setup_stackargs(FAR struct task_tcb_s *tcb, bool insert_name,
|
|||||||
* argument and its NUL terminator in the string buffer.
|
* argument and its NUL terminator in the string buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*stackargv++ = str;
|
stackargv[i + 1] = str;
|
||||||
nbytes = strlen(argv[i]) + 1;
|
nbytes = strlen(argv[i]) + 1;
|
||||||
strcpy(str, argv[i]);
|
strcpy(str, argv[i]);
|
||||||
str += nbytes;
|
str += nbytes;
|
||||||
@@ -590,7 +598,8 @@ nxtask_setup_stackargs(FAR struct task_tcb_s *tcb, bool insert_name,
|
|||||||
* nxtask_start().
|
* nxtask_start().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*stackargv++ = NULL;
|
stackargv[argc + 1] = NULL;
|
||||||
|
tcb->argv = stackargv;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -688,34 +697,19 @@ int pthread_setup_scheduler(FAR struct pthread_tcb_s *tcb, int priority,
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* tcb - Address of the new task's TCB
|
* tcb - Address of the new task's TCB
|
||||||
* insert_name - Insert name to the first argv
|
* name - Name of the new task (not used)
|
||||||
* name - Name of the new task
|
* argv - A pointer to an array of input parameters. The array should be
|
||||||
* argv - A pointer to an array of input parameters. The array
|
* terminated with a NULL argv[] value. If no parameters are
|
||||||
* should be terminated with a NULL argv[] value. If no
|
* required, argv may be NULL.
|
||||||
* parameters are required, argv may be NULL.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK
|
* OK
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nxtask_setup_arguments(FAR struct task_tcb_s *tcb, bool insert_name,
|
int nxtask_setup_arguments(FAR struct task_tcb_s *tcb, FAR const char *name,
|
||||||
FAR const char *name, FAR char * const argv[])
|
FAR char * const argv[])
|
||||||
{
|
{
|
||||||
/* Give a name to the unnamed tasks */
|
|
||||||
|
|
||||||
if (!name)
|
|
||||||
{
|
|
||||||
name = (FAR char *)g_noname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Always insert name if argv equals NULL */
|
|
||||||
|
|
||||||
if (!argv)
|
|
||||||
{
|
|
||||||
insert_name = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup the task name */
|
/* Setup the task name */
|
||||||
|
|
||||||
nxtask_setup_name(tcb, name);
|
nxtask_setup_name(tcb, name);
|
||||||
@@ -725,5 +719,5 @@ int nxtask_setup_arguments(FAR struct task_tcb_s *tcb, bool insert_name,
|
|||||||
* privilege mode the task runs in.
|
* privilege mode the task runs in.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return nxtask_setup_stackargs(tcb, insert_name, name, argv);
|
return nxtask_setup_stackargs(tcb, argv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr)
|
|||||||
name = parent->cmn.name;
|
name = parent->cmn.name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nxtask_setup_arguments(child, false, name, parent->argv);
|
nxtask_setup_arguments(child, name, parent->argv);
|
||||||
|
|
||||||
/* Now we have enough in place that we can join the group */
|
/* Now we have enough in place that we can join the group */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user