chiark / gitweb /
x86-model.c: Actually display the stepping.
[misc] / not.c
... / ...
CommitLineData
1#include <errno.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5
6#include <unistd.h>
7#include <sys/wait.h>
8
9int main(int argc, char *argv[])
10{
11 pid_t kid;
12 int rc;
13
14 if (argc < 2) {
15 fprintf(stderr, "usage: %s PROG [ARGS]\n", argv[0]);
16 exit(111);
17 }
18 kid = fork();
19 if (kid < 0) {
20 fprintf(stderr, "%s: fork: %s\n", argv[0], strerror(errno));
21 exit(111);
22 }
23 if (!kid) {
24 execvp(argv[1], argv + 1);
25 fprintf(stderr, "%s: exec %s: %s\n", argv[0], argv[1], strerror(errno));
26 exit(111);
27 }
28 if (waitpid(kid, &rc, 0) <= 0) {
29 fprintf(stderr, "%s: wait: %s\n", argv[0], strerror(errno));
30 exit(111);
31 }
32 if (!WIFEXITED(rc) || WEXITSTATUS(rc) == 111)
33 exit(111);
34 exit(WEXITSTATUS(rc) == 0 ? 100 : 0);
35}