summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/examples/create.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/examples/create.c b/src/examples/create.c
index 2702552..65be47d 100644
--- a/src/examples/create.c
+++ b/src/examples/create.c
@@ -9,12 +9,21 @@ main (int argc, char *argv[])
} else {
printf ("couldn't create file\n");
}
- int fd = open ("test");
+ int fd = open ("test"); // open 2
printf ("opened file with fd %d\n", fd);
- int fd2 = open ("test");
+ int fd2 = open ("test"); // open 3
printf ("opened file with fd %d\n", fd2);
- int fd3 = open ("test");
+ close(fd); // close 2
+ int fd3 = open ("test"); // open 2
printf ("opened file with fd %d\n", fd3);
+ close(fd2); // close 3
+ int fd4 = open ("test"); // open 3
+ printf ("opened file with fd %d\n", fd4);
+ close(fd4); // close 3, valid
+ close(fd3); // close 2, valid
+ close(fd); // close closed 2, invalid
+ int fd5 = open ("test"); // open 2
+ printf ("opened file with fd %d\n", fd5);
halt ();
}