aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/gen/wordexp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/wordexp.c')
-rw-r--r--lib/libc/gen/wordexp.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c
index 0902814eb04f..f8080c20d121 100644
--- a/lib/libc/gen/wordexp.c
+++ b/lib/libc/gen/wordexp.c
@@ -27,7 +27,6 @@
*/
#include "namespace.h"
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
@@ -266,7 +265,15 @@ cleanup:
errno = serrno;
return (error);
}
- if (wpid < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ /*
+ * Check process exit status, but ignore ECHILD as the child may have
+ * been automatically reaped if the process had set SIG_IGN or
+ * SA_NOCLDWAIT for SIGCHLD, and our reason for waitpid was just to
+ * reap our own child on behalf of the calling process.
+ */
+ if (wpid < 0 && errno != ECHILD)
+ return (WRDE_NOSPACE); /* abort for unknown reason */
+ if (wpid >= 0 && (!WIFEXITED(status) || WEXITSTATUS(status) != 0))
return (WRDE_NOSPACE); /* abort for unknown reason */
/*