aboutsummaryrefslogtreecommitdiff
path: root/tests/unistd/close.c
blob: 7110d18a7f04fa3dc92fd3afe01d3cf5c88eb453 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}