1
2
3
4
5
6
7
8
9
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <errno.h>
14int main (int argc, char *argv[])
15{
16 char *fnam = argv[0];
17 FILE *f;
18 if (argv[0][0] != '/')
19 {
20 fnam = malloc (strlen (argv[0]) + 2);
21 if (fnam == NULL)
22 abort ();
23 strcpy (fnam, "/");
24 strcat (fnam, argv[0]);
25 }
26
27 f = fopen (fnam, "rb");
28 if (f == NULL)
29 abort ();
30 close (f);
31
32
33 if (fopen ("/nonexistent", "rb") != NULL
34 || errno != ENOENT)
35 abort ();
36 printf ("pass\n");
37 return 0;
38}
39