Debian Codegraph @

tests/002_test_open.c

raw symbols SCIP
1 /*
2 open test */
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <fcntl.h>
6
7 void writeandclose(int a) {
8 write(a, "abc", 3);
9 close(a);
10 }
11
12 int main(int argc, char **argv) {
13 /* test that the three args work. */
14 int a, b, c;
15
16 if (argc < 4) {
17 exit(1);
18 }
19
20 a = open(argv[1], O_RDONLY);
21 b = open(argv[2], O_WRONLY);
22 c = open(argv[3], O_RDWR);
23 writeandclose(a);
24 writeandclose(b);
25 writeandclose(c);
26
27 return 0;
28 }