MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / runCommand

Function runCommand

programs/docker-init/docker-init.cpp:79–97  ·  view source on GitHub ↗

Run a command and wait for it. Returns the exit code (or -1 on error).

Source from the content-addressed store, hash-verified

77
78/// Run a command and wait for it. Returns the exit code (or -1 on error).
79int runCommand(const std::vector<std::string> & args)
80{
81 pid_t pid = fork();
82 if (pid < 0)
83 return -1;
84
85 if (pid == 0)
86 {
87 auto argv = buildArgv(args);
88 execvp(argv[0], argv.data());
89 _exit(127);
90 }
91
92 int status = 0;
93 while (waitpid(pid, &status, 0) < 0)
94 if (errno != EINTR)
95 return -1;
96 return WIFEXITED(status) ? WEXITSTATUS(status) : -1;
97}
98
99/// Run a command, capture its stdout, return {exit_code, output_lines}.
100std::pair<int, std::vector<std::string>> captureCommand(const std::vector<std::string> & args)

Callers 2

createClickHouseDatabaseFunction · 0.85
runInitScriptsFunction · 0.85

Calls 2

buildArgvFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected