diff options
author | Tim Moore <timoore@redhat.com> | 2009-09-16 19:06:29 +0200 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-09-30 20:40:30 +0200 |
commit | aac88aab720d169bacc49702f18996a5929a7f5d (patch) | |
tree | 592585b2932c52f6ce4924db5ea4f492cf1e3bb4 /grapher/StapParser.cxx | |
parent | 239edc45bc2215485362eda09422e380f02ad0c1 (diff) | |
download | systemtap-steved-aac88aab720d169bacc49702f18996a5929a7f5d.tar.gz systemtap-steved-aac88aab720d169bacc49702f18996a5929a7f5d.tar.xz systemtap-steved-aac88aab720d169bacc49702f18996a5929a7f5d.zip |
grapher: Handle the death of the child stap process
* grapher/grapher.c (main): Set up signal and i/o handlers to detect death
of child.
* grapher/StapParser.cxx (errIoCallback): New method
Diffstat (limited to 'grapher/StapParser.cxx')
-rw-r--r-- | grapher/StapParser.cxx | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index 47dfbe30..74b08170 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -1,5 +1,7 @@ #include "StapParser.hxx" +#include <unistd.h> + #include <gtkmm/window.h> #include <iostream> #include <sstream> @@ -65,11 +67,16 @@ vector<string> commaSplit(const string& inStr, size_t pos = 0) bool StapParser::ioCallback(Glib::IOCondition ioCondition) { using namespace std; + if (ioCondition & Glib::IO_HUP) + { + _win.hide(); + return true; + } if ((ioCondition & Glib::IO_IN) == 0) return true; char buf[256]; ssize_t bytes_read = 0; - bytes_read = read(0, buf, sizeof(buf) - 1); + bytes_read = read(STDIN_FILENO, buf, sizeof(buf) - 1); if (bytes_read <= 0) { _win.hide(); @@ -203,4 +210,22 @@ vector<string> commaSplit(const string& inStr, size_t pos = 0) } return true; } + + bool StapParser::errIoCallback(Glib::IOCondition ioCondition) + { + using namespace std; + if ((ioCondition & Glib::IO_IN) == 0) + return true; + char buf[256]; + ssize_t bytes_read = 0; + bytes_read = read(_errFd, buf, sizeof(buf) - 1); + if (bytes_read <= 0) + { + _win.hide(); + return true; + } + if (write(STDOUT_FILENO, buf, bytes_read) < 0) + ; + return true; + } } |