vendor: sync subprocess.h and drop local patches (#26808)

Upstream merged the Windows argument quoting fix, the NetBSD build
fix and the chdir fallback for glibc older than 2.29, so pin the
vendored copy to a commit that carries all three and remove the
patch files along with the apply step in the sync script.

The new pin also brings the exec error report on glibc older than
2.24 and the ENOSYS mapping to a dedicated error code. Both are
additive and no caller inspects those values.
This commit is contained in:
Pascal
2026-08-10 11:59:08 +02:00
committed by GitHub
parent 86c298fb8a
commit 4c6766fd7e
5 changed files with 36 additions and 198 deletions
+35 -3
View File
@@ -107,7 +107,8 @@ enum subprocess_error_e {
subprocess_error_permission_denied = -5,
subprocess_error_no_memory = -6,
subprocess_error_pipe = -7,
subprocess_error_spawn = -8
subprocess_error_spawn = -8,
subprocess_error_not_supported = -9
};
#if defined(__cplusplus)
@@ -275,8 +276,10 @@ subprocess_weak int subprocess_alive(struct subprocess_s *const process);
#endif
/* Whether subprocess_create_ex can honour process_cwd. glibc only gained
posix_spawn_file_actions_addchdir_np in 2.29. Define this yourself to
override the detection, for instance on musl older than 1.1.24. */
posix_spawn_file_actions_addchdir_np in 2.29, and macOS in 10.15; the SDKs
mark it unavailable on iOS, tvOS and watchOS, where the undefined version
macro folds to 0 and so answers correctly. Define this yourself to override
the detection, for instance on musl older than 1.1.24. */
#if !defined(SUBPROCESS_HAVE_CWD)
#if defined(__GLIBC__)
#if __GLIBC_PREREQ(2, 29)
@@ -284,11 +287,27 @@ subprocess_weak int subprocess_alive(struct subprocess_s *const process);
#else
#define SUBPROCESS_HAVE_CWD 0
#endif
#elif defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED < 101500
#define SUBPROCESS_HAVE_CWD 0
#else
#define SUBPROCESS_HAVE_CWD 1
#endif
#endif
/* Whether posix_spawn reports a failed exec back to the caller. glibc only
started doing so in 2.24; before that the child silently exits with 127. */
#if !defined(SUBPROCESS_SPAWN_REPORTS_EXEC_ERRORS)
#if defined(__GLIBC__)
#if __GLIBC_PREREQ(2, 24)
#define SUBPROCESS_SPAWN_REPORTS_EXEC_ERRORS 1
#else
#define SUBPROCESS_SPAWN_REPORTS_EXEC_ERRORS 0
#endif
#else
#define SUBPROCESS_SPAWN_REPORTS_EXEC_ERRORS 1
#endif
#endif
#if defined(_WIN32)
#include <wchar.h>
@@ -554,6 +573,8 @@ int subprocess_error_from_errno(int error) {
case ENFILE:
case ENOMEM:
return subprocess_error_no_memory;
case ENOSYS:
return subprocess_error_not_supported;
default:
return subprocess_error_unknown;
}
@@ -1358,6 +1379,17 @@ cleanup:
goto cleanup;
}
} else {
#if !SUBPROCESS_SPAWN_REPORTS_EXEC_ERRORS
/* posix_spawn cannot tell us the exec failed, so check up front */
if (0 != access(commandLine[0], X_OK)) {
saved_errno = errno;
result = subprocess_error_from_errno(saved_errno);
if (subprocess_error_unknown == result) {
result = subprocess_error_spawn;
}
goto cleanup;
}
#endif
posix_error = posix_spawn(&child, commandLine[0], &actions,
SUBPROCESS_NULL,
SUBPROCESS_CONST_CAST(char *const *, commandLine),