File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
system/lib/libc/musl/src/stdio Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ weak_alias(dummy, __aio_close);
1111int __stdio_close (FILE * f )
1212{
1313#ifdef __EMSCRIPTEN__
14- return __wasi_fd_close (__aio_close (f -> fd ));
14+ return __wasi_syscall_ret ( __wasi_fd_close (__aio_close (f -> fd ) ));
1515#else
1616 return syscall (SYS_close , __aio_close (f -> fd ));
1717#endif
Original file line number Diff line number Diff line change 44// found in the LICENSE file.
55
66#include <assert.h>
7+ #include <errno.h>
78#include <fcntl.h>
89#include <stdio.h>
910#include <stdlib.h>
1011#include <string.h>
1112#include <sys/stat.h>
1213#include <unistd.h>
1314
15+ void test_fclose () {
16+ FILE * f = fopen ("temp.txt" , "w" );
17+ int fd = fileno (f );
18+ // Close the underlying FD, which should then cause fclose to
19+ // fail.
20+ int ret = close (fd );
21+ assert (ret == 0 );
22+ ret = fclose (f );
23+ printf ("fclose error: %s\n" , strerror (errno ));
24+ assert (ret == EOF );
25+ }
26+
1427// Reading
1528void test_reading () {
1629 FILE * file = fopen ("somefile.binary" , "rb" );
@@ -161,6 +174,7 @@ void test_tempfiles() {
161174}
162175
163176int main () {
177+ test_fclose ();
164178 test_reading ();
165179 test_stdstreams ();
166180 test_writing ();
You can’t perform that action at this time.
0 commit comments