From: Josh Stone Date: Thu, 10 Feb 2011 22:54:18 +0000 (-0800) Subject: Read the pipe directly in stap_system_read X-Git-Tag: release-1.5~250 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=77455f9795385d07e95a1f88ff598121d978ab8b;p=systemtap.git Read the pipe directly in stap_system_read * util.cxx (stap_system_read): Use gnu's stdio_filebuf to read directly from the pipe file descriptor. --- diff --git a/util.cxx b/util.cxx index 01f20594e..fe4d5c038 100644 --- a/util.cxx +++ b/util.cxx @@ -24,6 +24,7 @@ #include #include #include +#include extern "C" { #include @@ -40,6 +41,7 @@ extern "C" { } using namespace std; +using namespace __gnu_cxx; // Return current users home directory or die. @@ -525,11 +527,9 @@ stap_system_read(int verbose, const string& command, ostream& out) spawned_pids.insert(child); // read everything from the child - string readpath = "/proc/self/fd/" + lex_cast(pfd[0]); - ifstream in(readpath.c_str()); - close(pfd[0]); + stdio_filebuf in(pfd[0], ios_base::in); close(pfd[1]); - out << in.rdbuf(); + out << ∈ return stap_waitpid(verbose, child); }