From aac88aab720d169bacc49702f18996a5929a7f5d Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 16 Sep 2009 19:06:29 +0200 Subject: 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 --- grapher/StapParser.cxx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'grapher/StapParser.cxx') 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 + #include #include #include @@ -65,11 +67,16 @@ vector 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 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; + } } -- cgit