summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-05-25 18:25:47 +0200
committerTim Moore <timoore@redhat.com>2009-07-28 10:15:33 +0200
commit95ddfc079a1d9affdb285f7690f8d5623cd7124a (patch)
tree7041ba1ca4fabda98523fc83d2b16606ce49450f
parentf7cfc39c07d0cf872559f9716643491b8d79de75 (diff)
downloadsystemtap-steved-95ddfc079a1d9affdb285f7690f8d5623cd7124a.tar.gz
systemtap-steved-95ddfc079a1d9affdb285f7690f8d5623cd7124a.tar.xz
systemtap-steved-95ddfc079a1d9affdb285f7690f8d5623cd7124a.zip
run stap from grapher
* grapher/grapher.cxx (main): Start stap + script from program if supplied as an argument.
-rw-r--r--grapher/grapher.cxx34
1 files changed, 32 insertions, 2 deletions
diff --git a/grapher/grapher.cxx b/grapher/grapher.cxx
index b7292cfd..0013d8b0 100644
--- a/grapher/grapher.cxx
+++ b/grapher/grapher.cxx
@@ -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;
}