MCPcopy Create free account
hub / github.com/NetSys/bess / RunCommand

Function RunCommand

core/debug.cc:200–214  ·  view source on GitHub ↗

Run an external command and return its standard output.

Source from the content-addressed store, hash-verified

198
199// Run an external command and return its standard output.
200static std::string RunCommand(std::string cmd) {
201 std::ostringstream ret;
202
203 FILE *proc = popen(cmd.c_str(), "r");
204 if (proc) {
205 while (!feof(proc)) {
206 char buf[PIPE_BUF];
207 size_t bytes = fread(buf, 1, sizeof(buf), proc);
208 ret.write(buf, bytes);
209 }
210 pclose(proc);
211 }
212
213 return ret.str();
214}
215
216// If mmap is used (as for shared objects), code address at runtime can be
217// arbitrary. This function translates an absolute address into a relative

Callers 1

PrintCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected