mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
fix wait after vfork return error
vfork use waitpid hang father process, but waitpid release child processs information by default. So when user call wait, it return errno 10. Signed-off-by: yangyalei <yangyalei@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
eba2f163ed
commit
fd776e8cee
@@ -628,7 +628,7 @@ static int goldfish_camera_data_uninit(FAR struct imgdata_s *data)
|
|||||||
|
|
||||||
priv->streaming = false;
|
priv->streaming = false;
|
||||||
nxsem_post(&priv->run);
|
nxsem_post(&priv->run);
|
||||||
nxsched_waitpid(priv->pid, NULL, 0, 0);
|
nxsched_waitpid(priv->pid, NULL, 0);
|
||||||
|
|
||||||
nxsem_destroy(&priv->run);
|
nxsem_destroy(&priv->run);
|
||||||
file_close(&priv->file);
|
file_close(&priv->file);
|
||||||
|
|||||||
@@ -1456,7 +1456,7 @@ void nxsched_get_stateinfo(FAR struct tcb_s *tcb, FAR char *state,
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pid - The task ID of the thread to waid for
|
* pid - The task ID of the thread to waid for
|
||||||
* stat_loc - The location to return the exit status
|
* stat_loc - The location to return the exit status
|
||||||
* options - ignored
|
* options - Modifiable behavior, see sys/wait.h.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* If nxsched_waitpid() returns because the status of a child process is
|
* If nxsched_waitpid() returns because the status of a child process is
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ pid_t vfork(void)
|
|||||||
* until running finished or performing exec
|
* until running finished or performing exec
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = waitpid(pid, &status, 0);
|
ret = waitpid(pid, &status, WNOWAIT);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
serr("ERROR: waitpid failed: %d\n", get_errno());
|
serr("ERROR: waitpid failed: %d\n", get_errno());
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pid - The task ID of the thread to waid for
|
* pid - The task ID of the thread to waid for
|
||||||
* stat_loc - The location to return the exit status
|
* stat_loc - The location to return the exit status
|
||||||
* options - ignored
|
* options - Modifiable behavior, see sys/wait.h.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* If nxsched_waitpid() returns because the status of a child process is
|
* If nxsched_waitpid() returns because the status of a child process is
|
||||||
@@ -388,8 +388,11 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options)
|
|||||||
|
|
||||||
/* Discard the child entry and break out of the loop */
|
/* Discard the child entry and break out of the loop */
|
||||||
|
|
||||||
group_remove_child(rtcb->group, pid);
|
if ((options & WNOWAIT) == 0)
|
||||||
group_free_child(child);
|
{
|
||||||
|
group_remove_child(rtcb->group, pid);
|
||||||
|
group_free_child(child);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -475,7 +478,7 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options)
|
|||||||
|
|
||||||
/* Discard the child entry, if we have one */
|
/* Discard the child entry, if we have one */
|
||||||
|
|
||||||
if (child != NULL)
|
if (child != NULL && (options & WNOWAIT) == 0)
|
||||||
{
|
{
|
||||||
group_remove_child(rtcb->group, child->ch_pid);
|
group_remove_child(rtcb->group, child->ch_pid);
|
||||||
group_free_child(child);
|
group_free_child(child);
|
||||||
@@ -591,7 +594,7 @@ errout:
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pid - The task ID of the thread to waid for
|
* pid - The task ID of the thread to waid for
|
||||||
* stat_loc - The location to return the exit status
|
* stat_loc - The location to return the exit status
|
||||||
* options - ignored
|
* options - Modifiable behavior, see sys/wait.h.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* If waitpid() returns because the status of a child process is available,
|
* If waitpid() returns because the status of a child process is available,
|
||||||
|
|||||||
Reference in New Issue
Block a user