aboutsummaryrefslogtreecommitdiff
path: root/tests/unistd/close.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unistd/close.c')
-rw-r--r--tests/unistd/close.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unistd/close.c b/tests/unistd/close.c
new file mode 100644
index 00000000..7110d18a
--- /dev/null
+++ b/tests/unistd/close.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+int main() {
+ int f = open("/", O_RDONLY);
+
+ printf("fsync(opened): %d\n", fsync(f));
+ printf("errno: %d\n", errno);
+ errno = 0;
+
+ printf("close(opened): %d\n", close(f));
+ printf("errno: %d\n", errno);
+ errno = 0;
+
+ printf("fsync(closed): %d\n", fsync(f));
+ printf("errno: %d\n", errno);
+ errno = 0;
+
+ printf("close(closed): %d\n", close(f));
+ printf("errno: %d\n", errno);
+ errno = 0;
+
+ return 0;
+}