Revert "fix wait after vfork return error"

This reverts commit 50428979d0.
This commit is contained in:
yangyalei 2023-09-07 21:28:01 +08:00 committed by Petro Karashchenko
parent f4f2c9ed49
commit eba2f163ed
3 changed files with 9 additions and 17 deletions

View File

@ -1457,7 +1457,6 @@ void nxsched_get_stateinfo(FAR struct tcb_s *tcb, FAR char *state,
* pid - The task ID of the thread to waid for
* stat_loc - The location to return the exit status
* options - ignored
* release - Wheather release exited child process infomation
*
* Returned Value:
* If nxsched_waitpid() returns because the status of a child process is
@ -1486,8 +1485,7 @@ void nxsched_get_stateinfo(FAR struct tcb_s *tcb, FAR char *state,
****************************************************************************/
#ifdef CONFIG_SCHED_WAITPID
pid_t nxsched_waitpid(pid_t pid, FAR int *stat_loc, int options,
bool release);
pid_t nxsched_waitpid(pid_t pid, FAR int *stat_loc, int options);
#endif
/****************************************************************************

View File

@ -23,7 +23,6 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/sched.h>
#include <unistd.h>
#include <sys/wait.h>
@ -64,11 +63,10 @@ pid_t vfork(void)
* until running finished or performing exec
*/
ret = nxsched_waitpid(pid, &status, 0, false);
ret = waitpid(pid, &status, 0);
if (ret < 0)
{
set_errno(-ret);
serr("ERROR: waitpid failed: %d\n", -ret);
serr("ERROR: waitpid failed: %d\n", get_errno());
}
}

View File

@ -62,7 +62,6 @@
* pid - The task ID of the thread to waid for
* stat_loc - The location to return the exit status
* options - ignored
* release - Wheather release exited child process infomation
*
* Returned Value:
* If nxsched_waitpid() returns because the status of a child process is
@ -91,7 +90,7 @@
****************************************************************************/
#ifndef CONFIG_SCHED_HAVE_PARENT
pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options, bool release)
pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options)
{
FAR struct tcb_s *ctcb;
FAR struct task_group_s *group;
@ -222,7 +221,7 @@ errout:
****************************************************************************/
#else
pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options, bool release)
pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options)
{
FAR struct tcb_s *rtcb = this_task();
FAR struct tcb_s *ctcb;
@ -389,11 +388,8 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options, bool release)
/* Discard the child entry and break out of the loop */
if (release)
{
group_remove_child(rtcb->group, pid);
group_free_child(child);
}
group_remove_child(rtcb->group, pid);
group_free_child(child);
break;
}
}
@ -479,7 +475,7 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options, bool release)
/* Discard the child entry, if we have one */
if (child != NULL && release)
if (child != NULL)
{
group_remove_child(rtcb->group, child->ch_pid);
group_free_child(child);
@ -640,7 +636,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
/* Let nxsched_waitpid() do the work. */
ret = nxsched_waitpid(pid, stat_loc, options, true);
ret = nxsched_waitpid(pid, stat_loc, options);
if (ret < 0)
{
set_errno(-ret);