File: 021_test_open.c

package info (click to toggle)
cowdancer 0.47
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 696 kB
  • ctags: 179
  • sloc: ansic: 2,634; sh: 407; makefile: 116; cpp: 6; python: 4
file content (27 lines) | stat: -rwxr-xr-x 422 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
/*BINFMTC:

  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;
}