Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Run Command

Functions for running external processes synchronously.

Source: kernel/c/root-linux/src/run_command.h


run_command()

Runs a shell command synchronously via popen() and captures its combined stdout/stderr output.

gbuffer_t *run_command(const char *command);

Parameters

KeyTypeDescription
commandconst char *Shell command string to execute.

Returns

gbuffer_t containing the command output, or NULL on error.

Notes


run_process2()

Runs a process synchronously using fork() with robust signal handling.

int run_process2(
    const char *path,
    char *const argv[]
);

Parameters

KeyTypeDescription
pathconst char *Full path to the executable.
argvchar *const []NULL-terminated argument vector.

Returns

Process exit status, or 127 if exec failed.


pty_sync_spawn()

Spawns a command synchronously in a pseudo-terminal (via forkpty()), providing interactive terminal I/O between parent and child.

int pty_sync_spawn(const char *command);

Parameters

KeyTypeDescription
commandconst char *Shell command to execute via /bin/sh -c.

Returns

0 on success, -1 on failure.