File: vim5.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (29 lines) | stat: -rw-r--r-- 740 bytes parent folder | download
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
29
#include "test.h"
#include <stdlib.h>
#include <sys/wait.h> // For WEXITSTATUS and related macros

int main(void) {
    int ret = system("XXXX"); // Intentionally invalid command

    if (ret == -1) {
        perror("system");
        return 1;
    }

    // Check if the command terminated normally
    if (WIFEXITED(ret)) {
        int exit_status = WEXITSTATUS(ret);
        printf("Command exited with status: %d\n", exit_status);

        if (exit_status == 127)
            printf("As expected: command not found\n");
        else
            printf("Unexpected exit status\n");

        ASSERT(127, exit_status);
    } else {
        printf("Command did not exit normally\n");
    }
    
    return 0;
}