From eba2f163edd5de53c0310d35aade3db44382cb17 Mon Sep 17 00:00:00 2001 From: yangyalei Date: Thu, 7 Sep 2023 21:28:01 +0800 Subject: [PATCH] Revert "fix wait after vfork return error" This reverts commit 50428979d0d1bb4c24c89bcc36a914158c56b373. --- include/nuttx/sched.h | 4 +--- libs/libc/unistd/lib_vfork.c | 6 ++---- sched/sched/sched_waitpid.c | 16 ++++++---------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index aaaecc4a01..47f2549ea2 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -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 /**************************************************************************** diff --git a/libs/libc/unistd/lib_vfork.c b/libs/libc/unistd/lib_vfork.c index 15c21fdd8c..e23014d26c 100644 --- a/libs/libc/unistd/lib_vfork.c +++ b/libs/libc/unistd/lib_vfork.c @@ -23,7 +23,6 @@ ****************************************************************************/ #include -#include #include #include @@ -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()); } } diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index 069808f4e1..ef535a62a8 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -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);