Drop main() prototype. Syncs with NetBSD-8
[minix.git] / minix / tests / test86.c
blob97ee3bf1f71fdc98f2c4c58b8b17791d7ff38e6d
1 #include <stdlib.h>
2 #include <string.h>
3 #include <limits.h>
4 #include <fcntl.h>
5 #include <sys/wait.h>
7 #include "common.h"
9 /*
10 * Test for dynamic executables with no read permissions. This test relies on
11 * being linked dynamically.
13 int
14 main(int argc, char ** argv)
16 char *executable, cp_cmd[PATH_MAX + 9];
17 int status;
19 if (strcmp(argv[0], "DO CHECK") == 0)
20 exit(EXIT_SUCCESS);
22 start(86);
24 /* Make a copy of this binary which is executable-only. */
25 executable = argv[0];
27 snprintf(cp_cmd, sizeof(cp_cmd), "cp ../%s .", executable);
28 status = system(cp_cmd);
29 if (status < 0 || !WIFEXITED(status) ||
30 WEXITSTATUS(status) != EXIT_SUCCESS) e(0);
32 if (chmod(executable, S_IXUSR) != 0) e(0);
34 /* Invoke the changed binary in a child process. */
35 switch (fork()) {
36 case -1:
37 e(0);
38 case 0:
39 execl(executable, "DO CHECK", NULL);
41 exit(EXIT_FAILURE);
42 default:
43 if (wait(&status) <= 0) e(0);
44 if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS)
45 e(0);
48 quit();
49 /* NOTREACHED */