diff options
author | max99x <max99x@gmail.com> | 2011-07-23 05:49:48 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-07-23 05:49:48 +0300 |
commit | 136756f734ecf14a28736900075d561e981e973e (patch) | |
tree | cf33472ea6550c6486ec7722facf34d98a16a51d /tests/unistd/dup.c | |
parent | 586d229ec311daa5e89781eb6da822989e677789 (diff) |
Added unistd tests; fixed a lot of unistd bugs and deficiencies.
Diffstat (limited to 'tests/unistd/dup.c')
-rw-r--r-- | tests/unistd/dup.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/unistd/dup.c b/tests/unistd/dup.c new file mode 100644 index 00000000..8b4dca34 --- /dev/null +++ b/tests/unistd/dup.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> + +int main() { + int f, f2, f3; + + printf("DUP\n"); + f = open("/", O_RDONLY); + f2 = open("/", O_RDONLY); + f3 = dup(f); + printf("errno: %d\n", errno); + printf("f: %d\n", f); + printf("f2: %d\n", f2); + printf("f3: %d\n", f3); + printf("close(f1): %d\n", close(f)); + printf("close(f2): %d\n", close(f2)); + printf("close(f3): %d\n", close(f3)); + printf("\n"); + errno = 0; + + printf("DUP2\n"); + f = open("/", O_RDONLY); + f2 = open("/", O_RDONLY); + f3 = dup2(f, f2); + printf("errno: %d\n", errno); + printf("f: %d\n", f); + printf("f2: %d\n", f2); + printf("f3: %d\n", f3); + printf("close(f1): %d\n", close(f)); + printf("close(f2): %d\n", close(f2)); + printf("close(f3): %d\n", close(f3)); + printf("\n"); + errno = 0; + + return 0; +} |