diff --git a/drivers/video/goldfish_camera.c b/drivers/video/goldfish_camera.c index 55996c11af..044a18159a 100644 --- a/drivers/video/goldfish_camera.c +++ b/drivers/video/goldfish_camera.c @@ -628,7 +628,7 @@ static int goldfish_camera_data_uninit(FAR struct imgdata_s *data) priv->streaming = false; nxsem_post(&priv->run); - nxsched_waitpid(priv->pid, NULL, 0, 0); + nxsched_waitpid(priv->pid, NULL, 0); nxsem_destroy(&priv->run); file_close(&priv->file); diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 47f2549ea2..cb1715ce15 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -1456,7 +1456,7 @@ void nxsched_get_stateinfo(FAR struct tcb_s *tcb, FAR char *state, * Input Parameters: * pid - The task ID of the thread to waid for * stat_loc - The location to return the exit status - * options - ignored + * options - Modifiable behavior, see sys/wait.h. * * Returned Value: * If nxsched_waitpid() returns because the status of a child process is diff --git a/libs/libc/unistd/lib_vfork.c b/libs/libc/unistd/lib_vfork.c index e23014d26c..b7e97be38e 100644 --- a/libs/libc/unistd/lib_vfork.c +++ b/libs/libc/unistd/lib_vfork.c @@ -63,7 +63,7 @@ pid_t vfork(void) * until running finished or performing exec */ - ret = waitpid(pid, &status, 0); + ret = waitpid(pid, &status, WNOWAIT); if (ret < 0) { serr("ERROR: waitpid failed: %d\n", get_errno()); diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index ef535a62a8..078a35a7ba 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -61,7 +61,7 @@ * Input Parameters: * pid - The task ID of the thread to waid for * stat_loc - The location to return the exit status - * options - ignored + * options - Modifiable behavior, see sys/wait.h. * * Returned Value: * 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 */ - group_remove_child(rtcb->group, pid); - group_free_child(child); + if ((options & WNOWAIT) == 0) + { + group_remove_child(rtcb->group, pid); + group_free_child(child); + } 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 */ - if (child != NULL) + if (child != NULL && (options & WNOWAIT) == 0) { group_remove_child(rtcb->group, child->ch_pid); group_free_child(child); @@ -591,7 +594,7 @@ errout: * Input Parameters: * pid - The task ID of the thread to waid for * stat_loc - The location to return the exit status - * options - ignored + * options - Modifiable behavior, see sys/wait.h. * * Returned Value: * If waitpid() returns because the status of a child process is available,