This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 7479d4f8f66 libs/libc/unistd: Add wait3().
7479d4f8f66 is described below

commit 7479d4f8f66a48cae557b0878c2995e1c439bc7b
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Oct 20 16:24:44 2026 +0200

    libs/libc/unistd: Add wait3().
    
    wait3() waits for any child and returns its resource usage, as
    wait4(-1, ...).  POSIX no longer has it, but programs still call it.
    
    Add it next to wait4(), with the same condition (CONFIG_SCHED_WAITPID).
    Both are now in lib_wait.c (was lib_wait4.c).
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/sys/wait.h                           |  6 ++++--
 libs/libc/unistd/CMakeLists.txt              |  2 +-
 libs/libc/unistd/Make.defs                   |  2 +-
 libs/libc/unistd/{lib_wait4.c => lib_wait.c} | 15 ++++++++++++++-
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/sys/wait.h b/include/sys/wait.h
index 2f3b6a9142a..7d71e5625db 100644
--- a/include/sys/wait.h
+++ b/include/sys/wait.h
@@ -96,12 +96,14 @@ pid_t wait(FAR int *stat_loc);
 int   waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options);
 pid_t waitpid(pid_t pid, FAR int *stat_loc, int options);
 
-/* wait4() is waitpid() plus the reaped child's struct rusage in one call.
+/* wait4() is waitpid() plus the reaped child's struct rusage in one call,
+ * and wait3() is wait4() for any child.
  * struct rusage is forward-declared here (not #include <sys/resource.h>)
- * since it is only ever used as a pointer type in this prototype.
+ * since it is only ever used as a pointer type in these prototypes.
  */
 
 struct rusage;
+pid_t wait3(FAR int *stat_loc, int options, FAR struct rusage *rusage);
 pid_t wait4(pid_t pid, FAR int *stat_loc, int options,
             FAR struct rusage *rusage);
 
diff --git a/libs/libc/unistd/CMakeLists.txt b/libs/libc/unistd/CMakeLists.txt
index cabaeb34f32..261dec9516e 100644
--- a/libs/libc/unistd/CMakeLists.txt
+++ b/libs/libc/unistd/CMakeLists.txt
@@ -75,7 +75,7 @@ set(SRCS
     lib_ulimit.c)
 
 if(CONFIG_SCHED_WAITPID)
-  list(APPEND SRCS lib_wait4.c)
+  list(APPEND SRCS lib_wait.c)
 endif()
 
 if(NOT CONFIG_SCHED_USER_IDENTITY)
diff --git a/libs/libc/unistd/Make.defs b/libs/libc/unistd/Make.defs
index 42d839ff6ce..a4849f3e8d2 100644
--- a/libs/libc/unistd/Make.defs
+++ b/libs/libc/unistd/Make.defs
@@ -38,7 +38,7 @@ CSRCS += lib_lockf.c lib_flock.c lib_getpass.c
 CSRCS += lib_chdir.c lib_fchdir.c lib_confstr.c lib_ulimit.c
 
 ifeq ($(CONFIG_SCHED_WAITPID),y)
-CSRCS += lib_wait4.c
+CSRCS += lib_wait.c
 endif
 
 ifneq ($(CONFIG_SCHED_USER_IDENTITY),y)
diff --git a/libs/libc/unistd/lib_wait4.c b/libs/libc/unistd/lib_wait.c
similarity index 86%
rename from libs/libc/unistd/lib_wait4.c
rename to libs/libc/unistd/lib_wait.c
index 747eeb3d3f3..75e917969b0 100644
--- a/libs/libc/unistd/lib_wait4.c
+++ b/libs/libc/unistd/lib_wait.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/unistd/lib_wait4.c
+ * libs/libc/unistd/lib_wait.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -62,3 +62,16 @@ pid_t wait4(pid_t pid, FAR int *stat_loc, int options,
 
   return ret;
 }
+
+/****************************************************************************
+ * Name: wait3
+ *
+ * Description:
+ *   Wait for any child, as wait4(-1, ...).
+ *
+ ****************************************************************************/
+
+pid_t wait3(FAR int *stat_loc, int options, FAR struct rusage *rusage)
+{
+  return wait4(-1, stat_loc, options, rusage);
+}

Reply via email to