socket: Shortcircuit FIONBIO in soo_ioctl().
[dragonfly.git] / test / sockext / checkfd / checkfd.c
1 #include <errno.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5
6 int
7 main(int argc, char *argv[])
8 {
9         int i;
10
11         if (argc < 2)
12                 exit(1);
13
14         for (i = 1; i < argc; ++i) {
15                 char *endptr;
16                 int fd;
17
18                 fd = strtol(argv[i], &endptr, 10);
19                 if (*endptr != '\0')
20                         exit(1);
21
22                 if (close(fd) < 0) {
23                         int error = errno;
24
25                         if (error != EBADF) {
26                                 fprintf(stderr, "close error %d\n", error);
27                                 exit(2);
28                         }
29                 } else {
30                         fprintf(stderr, "%d is still valid\n", fd);
31                         exit(2);
32                 }
33         }
34         exit(0);
35 }