From 68ec443e0737f0135d01cde4ff2d5d4289f381fb Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 11 Jun 2023 01:10:28 +0300 Subject: [PATCH] LibC: implement close --- libc/stdio.cpp | 2 +- libc/unistd.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libc/stdio.cpp b/libc/stdio.cpp index 6e9da2e8..d4db1cb3 100644 --- a/libc/stdio.cpp +++ b/libc/stdio.cpp @@ -52,7 +52,7 @@ char* ctermid(char* buffer) int fclose(FILE* file) { - if (syscall(SYS_CLOSE, file->fd) < 0) + if (close(file->fd) == -1) return EOF; file->fd = -1; return 0; diff --git a/libc/unistd.cpp b/libc/unistd.cpp index 5ee00978..95bfd750 100644 --- a/libc/unistd.cpp +++ b/libc/unistd.cpp @@ -187,6 +187,11 @@ long syscall(long syscall, ...) return ret; } +int close(int fd) +{ + return syscall(SYS_CLOSE, fd); +} + int execl(const char* pathname, const char* arg0, ...) { if (arg0 == nullptr)