Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

system — pass a command to the command processor

The system function from <stdlib.h> passes text to the environment's command processor. A NULL argument only queries its availability.

Version: C23; repository compiler flag, production runtime not attested

Syntax

#include <stdlib.h>
int system(const char *string);

system is declared in <stdlib.h>. With NULL, it queries command-processor availability: nonzero means available, and zero means unavailable. No command is executed in this case. An empty string "" is not a null pointer.

With a non-null pointer, it passes the pointed-to string for execution in an implementation-documented manner. If the call returns, its result is implementation-defined; do not portably interpret it as a program's exit code. Execution can also terminate the calling program.

Do not construct commands from untrusted data: it may be interpreted as instructions. The example only queries availability. N3096 is a C23 draft; the repository compiler flag does not attest production runtime behavior.

Examples

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int available = system(NULL) != 0;
    printf("command_processor=%d\n", available);
    return 0;
}

Result

command_processor=1

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources