File: 002_test_open.c

package info (click to toggle)
cowdancer 0.90
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 648 kB
  • sloc: ansic: 4,593; sh: 407; makefile: 142; cpp: 5
file content (28 lines) | stat: -rw-r--r-- 417 bytes parent folder | download | duplicates (5)
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
27
28
/*
open test */
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

void writeandclose(int a) {
	write(a, "abc", 3);
	close(a);
}

int main(int argc, char **argv) {
	/* test that the three args work. */
	int a, b, c;

	if (argc < 4) {
		exit(1);
	}

	a = open(argv[1], O_RDONLY);
	b = open(argv[2], O_WRONLY);
	c = open(argv[3], O_RDWR);
	writeandclose(a);
	writeandclose(b);
	writeandclose(c);

	return 0;
}