-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfdcheck.c
43 lines (39 loc) · 1.24 KB
/
fdcheck.c
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
38
39
40
41
42
43
/* ************************************************************************** */
/* */
/* : . */
/* fdcheck.c -=-:::+*+:-+*#. */
/* :-:::+#***********----: */
/* By: csteenvo <csteenvo@student.codam.n> .:-*#************#- */
/* :=+*+=+*********####+: */
/* Created: 2022/05/10 11:58:54 by csteenvo .. +**=-=***- */
/* Updated: 2022/05/10 11:58:54 by csteenvo : .. */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <fcntl.h>
#include <limits.h>
#include <errno.h>
int
main(void)
{
int i;
int count;
count = 0;
i = 0;
while (i < OPEN_MAX)
{
if (fcntl(i, F_GETFD) < 0)
{
if (errno != EBADF)
fprintf(stderr, "Error\n");
}
else
{
printf("%d OPEN; ", i);
count++;
}
i++;
}
printf("\n%d/%d open\n", count, OPEN_MAX);
return (0);
}