[libc-commits] [libc] [libc] Implement freopen (PR #207837)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Wed Jul 8 07:50:49 PDT 2026


================
@@ -54,21 +56,17 @@ ErrorOr<off_t> linux_file_seek(File *f, off_t offset, int whence) {
 int linux_file_close(File *f) {
   File::remove_file(f);
   auto *lf = reinterpret_cast<LinuxFile *>(f);
-  int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_close, lf->get_fd());
-  if (ret < 0) {
-    return -ret;
+  if (lf->get_fd() >= 0) {
+    auto result = linux_syscalls::close(lf->get_fd());
+    if (!result)
+      return result.error();
----------------
kaladron wrote:

This does a delete lf below, but not here.  Is that correct?

https://github.com/llvm/llvm-project/pull/207837


More information about the libc-commits mailing list