[libc-commits] [libc] Libc: Never consider an fd being 0 as an error when opening (PR #176581)
via libc-commits
libc-commits at lists.llvm.org
Sun Jan 18 21:33:53 PST 2026
https://github.com/AZero13 updated https://github.com/llvm/llvm-project/pull/176581
>From bf34e5acb0a18172fad4b37503437cb15df455b6 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Sat, 17 Jan 2026 12:48:30 -0500
Subject: [PATCH] Libc: Never consider an fd being 0 as an error when opening
This is not semantically right, as we can get 0 when calling open.
---
libc/src/spawn/linux/posix_spawn.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/src/spawn/linux/posix_spawn.cpp b/libc/src/spawn/linux/posix_spawn.cpp
index fe82ba260148a..f05815805dc05 100644
--- a/libc/src/spawn/linux/posix_spawn.cpp
+++ b/libc/src/spawn/linux/posix_spawn.cpp
@@ -44,7 +44,7 @@ cpp::optional<int> open(const char *path, int oflags, mode_t mode) {
int fd = LIBC_NAMESPACE::syscall_impl<int>(SYS_openat, AT_FDCWD, path, oflags,
mode);
#endif
- if (fd > 0)
+ if (fd >= 0)
return fd;
// The open function is called as part of the child process' preparatory
// steps. If an open fails, the child process just exits. So, unlike
More information about the libc-commits
mailing list