summaryrefslogtreecommitdiff
path: root/tests/bionic/libc/other/test_system.c
blob: adb4c56a13276b40aea07e4954ea7327dd77ab6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdlib.h>
#include <stdio.h>
#include <sys/wait.h>
#include <errno.h>

int
main(int argc, char *argv[])
{
    int rv;

    if (argc < 2)
        return -1;

    rv = system(argv[1]);
    if (rv < 0) {
        fprintf(stderr, "Error calling system(): %d\n", errno);
        return 1;
    }

    printf("Done!\n");

    if (WEXITSTATUS(rv) != 0) {
        fprintf(stderr, "Command returned non-zero exit code: %d\n",
                WEXITSTATUS(rv));
        return 1;
    }
    return 0;
}