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);
11
11
int __stdio_close (FILE * f )
12
12
{
13
13
#ifdef __EMSCRIPTEN__
14
- return __wasi_fd_close (__aio_close (f -> fd ));
14
+ return __wasi_syscall_ret ( __wasi_fd_close (__aio_close (f -> fd ) ));
15
15
#else
16
16
return syscall (SYS_close , __aio_close (f -> fd ));
17
17
#endif
Original file line number Diff line number Diff line change 4
4
// found in the LICENSE file.
5
5
6
6
#include <assert.h>
7
+ #include <errno.h>
7
8
#include <fcntl.h>
8
9
#include <stdio.h>
9
10
#include <stdlib.h>
10
11
#include <string.h>
11
12
#include <sys/stat.h>
12
13
#include <unistd.h>
13
14
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
+
14
27
// Reading
15
28
void test_reading () {
16
29
FILE * file = fopen ("somefile.binary" , "rb" );
@@ -161,6 +174,7 @@ void test_tempfiles() {
161
174
}
162
175
163
176
int main () {
177
+ test_fclose ();
164
178
test_reading ();
165
179
test_stdstreams ();
166
180
test_writing ();
You can’t perform that action at this time.
0 commit comments