aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules/ady2.c
blob: 95eb0d178252243a92350bb766572582bc92684b (plain)
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
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <console.h>
#include <errno.h>

int main(int argc, char *argv[])
{
    static unsigned char iterations = 1;
    int src_fd;

    openconsole(&dev_stdcon_r, &dev_stdcon_w);

    if (argc < 2) {
	fprintf(stderr, "Usage: %s filename...\n", argv[0]);
	return 1;
    }

    while (1) {

	errno = 0;
	printf("---OPEN---");
	src_fd = open(argv[1], O_RDONLY);
	if (src_fd < 0) {
	    printf("Finally failed after %u iterations with error: %d\n",
		   iterations, errno);
	    return 1;
	}
	close(src_fd);
	printf("---CLOSE---");
	if (!iterations++)
	    return 1;
    }
    printf("No failure\n");
    return 0;
}