]> sourceware.org Git - systemtap.git/commitdiff
run stap from grapher
authorTim Moore <timoore@redhat.com>
Mon, 25 May 2009 16:25:47 +0000 (18:25 +0200)
committerTim Moore <timoore@redhat.com>
Tue, 28 Jul 2009 08:15:33 +0000 (10:15 +0200)
* grapher/grapher.cxx (main): Start stap + script from program if supplied
as an argument.

grapher/grapher.cxx

index b7292cfdce4ae2cb92ddb245c674a89214591354..0013d8b049857e4d5a4a4cf7232ca310f3798344 100644 (file)
@@ -97,12 +97,42 @@ int main(int argc, char** argv)
 
   StapParser stapParser(win, win.w);
 
-   StapParser stapParser(win, w);
+  int childPid = -1;
+  if (argc > 1)
+    {
+      int pipefd[2];
+      if (pipe(pipefd) < 0)
+        {
+          std::perror("pipe");
+          exit(1);
+        }
+      if ((childPid = fork()) == -1)
+        {
+          exit(1);
+        }
+      else if (childPid)
+        {
+          dup2(pipefd[0], 0);
+          close(pipefd[0]);
+        }
+      else
+        {
+          dup2(pipefd[1], 1);
+          close(pipefd[1]);
+          execlp("stap", argv[1]);
+          exit(1);
+          return 1;
+        }
+     }
    Glib::signal_io().connect(sigc::mem_fun(stapParser,
                                            &StapParser::ioCallback),
                              0,
                              Glib::IO_IN);
    Gtk::Main::run(win);
-
+   if (childPid > 0)
+   kill(childPid, SIGTERM);
+   int status;
+   while (wait(&status) != -1)
+     ;
    return 0;
 }
This page took 0.030262 seconds and 5 git commands to generate.