]> sourceware.org Git - systemtap.git/commitdiff
Read the pipe directly in stap_system_read
authorJosh Stone <jistone@redhat.com>
Thu, 10 Feb 2011 22:54:18 +0000 (14:54 -0800)
committerJosh Stone <jistone@redhat.com>
Thu, 10 Feb 2011 22:54:18 +0000 (14:54 -0800)
* util.cxx (stap_system_read): Use gnu's stdio_filebuf to read directly
  from the pipe file descriptor.

util.cxx

index 01f20594e22390ad0448b01b8fa017d3ebd19711..fe4d5c0381be352634d3ea26f0cc4d41b1c28e8f 100644 (file)
--- a/util.cxx
+++ b/util.cxx
@@ -24,6 +24,7 @@
 #include <string>
 #include <fstream>
 #include <cassert>
+#include <ext/stdio_filebuf.h>
 
 extern "C" {
 #include <fcntl.h>
@@ -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<char> in(pfd[0], ios_base::in);
   close(pfd[1]);
-  out << in.rdbuf();
+  out << &in;
 
   return stap_waitpid(verbose, child);
 }
This page took 0.045422 seconds and 5 git commands to generate.