#include #include int main (int argc, char *argv[]) { if (create ("test", 1)) { printf ("created file\n"); } else { printf ("couldn't create file\n"); } int fd = open ("test"); // open 2 printf ("opened file with fd %d\n", fd); int fd2 = open ("test"); // open 3 printf ("opened file with fd %d\n", fd2); 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 (); }