Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / test / not.c
bloba323b7b6c386923e9eda4ce763158a498056bb38
1 /* $NetBSD$ */
3 #include <unistd.h>
4 #include <stdio.h>
5 #include <stdarg.h>
6 #include <sys/types.h>
7 #include <sys/wait.h>
9 int main(int args, char **argv) {
10 pid_t pid;
11 int status;
12 int FAILURE = 6;
14 if (args < 2) {
15 fprintf(stderr, "Need args\n");
16 return FAILURE;
19 pid = fork();
20 if (pid == -1) {
21 fprintf(stderr, "Could not fork\n");
22 return FAILURE;
23 } else if (pid == 0) { /* child */
24 execvp(argv[1], &argv[1]);
25 /* should not be accessible */
26 return FAILURE;
27 } else { /* parent */
28 waitpid(pid, &status, 0);
29 if (!WIFEXITED(status)) {
30 if (WIFSIGNALED(status))
31 fprintf(stderr,
32 "Process %d died of signal %d.\n",
33 pid, WTERMSIG(status));
34 /* did not exit correctly */
35 return FAILURE;
37 /* return the opposite */
38 return !WEXITSTATUS(status);
40 /* not accessible */
41 return FAILURE;