test_system.c revision ab8beedeb70c6941e0ff68014d8db64cee4ef15d
1#include <stdlib.h>
2#include <stdio.h>
3#include <sys/wait.h>
4#include <errno.h>
5
6int
7main(int argc, char *argv[])
8{
9    int rv;
10
11    if (argc < 2)
12        return -1;
13
14    rv = system(argv[1]);
15    if (rv < 0) {
16        fprintf(stderr, "Error calling system(): %d\n", errno);
17        return 1;
18    }
19
20    printf("Done!\n");
21
22    if (WEXITSTATUS(rv) != 0) {
23        fprintf(stderr, "Command returned non-zero exit code: %d\n",
24                WEXITSTATUS(rv));
25        return 1;
26    }
27    return 0;
28}
29