File: 021_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 (26 lines) | stat: -rw-r--r-- 409 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
/*

  test 
  close(0);
  open(XXX,XXX);
  will return '0' as file ID.

 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int ac, const char **av) {
	int fd1, fd2;
	close(0);
	fd1 = open(av[1], O_RDONLY);
	close(0);
	fd2 = open(av[1], O_RDONLY);

	printf("close(0)open(): try1: %i, try2: %i\n", fd1, fd2);

	return fd1;
}