Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
542e706d
Commit
542e706d
authored
10 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Fix a perverse case where vfork() is called from a pthread. Still not recommended
parent
b693fb35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sched/task/task_vfork.c
+29
-16
29 additions, 16 deletions
sched/task/task_vfork.c
with
29 additions
and
16 deletions
sched/task/task_vfork.c
+
29
−
16
View file @
542e706d
...
...
@@ -79,12 +79,12 @@
****************************************************************************/
#if CONFIG_TASK_NAME_SIZE > 0
static
inline
void
vfork_namesetup
(
FAR
struct
task_
tcb_s
*
parent
,
static
inline
void
vfork_namesetup
(
FAR
struct
tcb_s
*
parent
,
FAR
struct
task_tcb_s
*
child
)
{
/* Copy the name from the parent into the child TCB */
strncpy
(
child
->
cmn
.
name
,
parent
->
cmn
.
name
,
CONFIG_TASK_NAME_SIZE
);
strncpy
(
child
->
cmn
.
name
,
parent
->
name
,
CONFIG_TASK_NAME_SIZE
);
}
#else
# define vfork_namesetup(p,c)
...
...
@@ -106,27 +106,40 @@ static inline void vfork_namesetup(FAR struct task_tcb_s *parent,
*
****************************************************************************/
static
inline
void
vfork_stackargsetup
(
FAR
struct
task_
tcb_s
*
parent
,
static
inline
void
vfork_stackargsetup
(
FAR
struct
tcb_s
*
parent
,
FAR
struct
task_tcb_s
*
child
)
{
uintptr_t
offset
;
int
i
;
/* Is the parent a task? or a pthread? */
/* Get the address correction */
child
->
argv
=
NULL
;
if
((
parent
->
flags
&
TCB_FLAG_TTYPE_MASK
)
!=
TCB_FLAG_TTYPE_PTHREAD
)
{
FAR
struct
task_tcb_s
*
ptcb
=
(
FAR
struct
task_tcb_s
*
)
parent
;
uintptr_t
offset
;
int
i
;
offset
=
child
->
cmn
.
xcp
.
regs
[
REG_SP
]
-
parent
->
cmn
.
xcp
.
regs
[
REG_SP
];
/* Get the address correction */
/* Copy the adjusted address for each argument */
offset
=
child
->
cmn
.
xcp
.
regs
[
REG_SP
]
-
parent
->
xcp
.
regs
[
REG_SP
];
for
(
i
=
0
;
i
<
CONFIG_MAX_TASK_ARGS
&&
parent
->
argv
[
i
];
i
++
)
{
uintptr_t
newaddr
=
(
uintptr_t
)
parent
->
argv
[
i
]
+
offset
;
child
->
argv
[
i
]
=
(
FAR
char
*
)
newaddr
;
}
/* Change the child argv[] to point into its stack (instead of its
* parent's stack).
*/
child
->
argv
=
(
FAR
char
**
)((
uintptr_t
)
ptcb
->
argv
+
offset
);
/*
Put a terminator entry at the end of the child argv[] array.
*/
/*
Copy the adjusted address for each argument
*/
child
->
argv
[
i
]
=
NULL
;
for
(
i
=
0
;
i
<
CONFIG_MAX_TASK_ARGS
&&
ptcb
->
argv
[
i
];
i
++
)
{
uintptr_t
newaddr
=
(
uintptr_t
)
ptcb
->
argv
[
i
]
+
offset
;
child
->
argv
[
i
]
=
(
FAR
char
*
)
newaddr
;
}
/* Put a terminator entry at the end of the child argv[] array. */
child
->
argv
[
i
]
=
NULL
;
}
}
/****************************************************************************
...
...
@@ -144,7 +157,7 @@ static inline void vfork_stackargsetup(FAR struct task_tcb_s *parent,
*
****************************************************************************/
static
inline
void
vfork_argsetup
(
FAR
struct
task_
tcb_s
*
parent
,
static
inline
void
vfork_argsetup
(
FAR
struct
tcb_s
*
parent
,
FAR
struct
task_tcb_s
*
child
)
{
/* Clone the task name */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment