Skip to content

Commit

Permalink
Make fopen work completely.
Browse files Browse the repository at this point in the history
  • Loading branch information
pizlonator committed Jul 14, 2024
1 parent 88ec27a commit d89a258
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/stdio/fopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdfil.h>
#include <pizlonated_musl_syscalls.h>

FILE *fopen(const char *restrict filename, const char *restrict mode)
{
Expand All @@ -22,11 +22,11 @@ FILE *fopen(const char *restrict filename, const char *restrict mode)
fd = zsys_open(filename, flags, 0666);
if (fd < 0) return 0;
if (flags & O_CLOEXEC)
__syscall(SYS_fcntl, fd, F_SETFD, FD_CLOEXEC);
zsys_fcntl(fd, F_SETFD, FD_CLOEXEC);

f = __fdopen(fd, mode);
if (f) return f;

__syscall(SYS_close, fd);
zsys_close(fd);
return 0;
}

0 comments on commit d89a258

Please sign in to comment.