Drop main() prototype. Syncs with NetBSD-8
[minix.git] / minix / tests / t40g.c
blob038a907db3c59fd2a7b0336b15027ae5044339f1
1 /* t40g.c
3 * Test select on character driver that does not support select
5 * We use /dev/zero for this right now. If the memory driver ever implements
6 * select support, this test should be changed to use another character driver.
7 */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <sys/types.h>
13 #include <sys/select.h>
14 #include <sys/wait.h>
15 #include <sys/time.h>
16 #include <time.h>
17 #include <errno.h>
18 #include <string.h>
19 #include <signal.h>
20 #include <fcntl.h>
22 #include "common.h"
24 int
25 main(int argc, char **argv)
27 fd_set set;
28 int fd, retval;
30 /* Get subtest number */
31 if (argc != 2 || sscanf(argv[1], "%d", &subtest) != 1) {
32 printf("Usage: %s subtest_no\n", argv[0]);
33 exit(-2);
37 * Do a select on /dev/zero, with the expectation that it will fail
38 * with an EBADF error code.
40 fd = open("/dev/zero", O_RDONLY);
41 if (fd < 0) em(1, "unable to open /dev/zero");
43 FD_ZERO(&set);
44 FD_SET(fd, &set);
46 retval = select(fd + 1, &set, NULL, NULL, NULL);
47 if (retval != -1) em(2, "select call was expected to fail");
48 if (errno != EBADF) em(3, "error code other than EBADF returned");
49 if (!FD_ISSET(fd, &set)) em(4, "file descriptor set was modified");
51 exit(errct);