diff options
author | Tim Moore <timoore@redhat.com> | 2009-12-10 21:34:27 +0100 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-12-10 21:34:27 +0100 |
commit | 1b9fad80af5504ef03c2a88504dbc47bea003721 (patch) | |
tree | 316616e898f5c4b7375759ac857d3eca1b4beac5 /grapher/StapParser.cxx | |
parent | b35632fd3d2547414c80023c5c60c847e3dc92ea (diff) | |
download | systemtap-steved-1b9fad80af5504ef03c2a88504dbc47bea003721.tar.gz systemtap-steved-1b9fad80af5504ef03c2a88504dbc47bea003721.tar.xz systemtap-steved-1b9fad80af5504ef03c2a88504dbc47bea003721.zip |
grapher: integrate graph events from stdin with the stap process framework.
This was the original way to do graphing and had bitrotted some.
* grapher/StapParser.cxx (initIO): new catchHUP argument
(ioCallback): Only disconnect signals, etc. on IN_HUP if catchHUP is
true.
(errIoCallback): Write error messages to stderr, not stdout.
* grapher/grapher.cxx (StapLauncher::launch): Don't catchHUP on our
stap process children.
(ProcWindow::refresh): Display something reasonable for the stap
"process" that is feeding stdin.
(main): Use StapParser::initIO to initialize parser reading from
stdin.
Diffstat (limited to 'grapher/StapParser.cxx')
-rw-r--r-- | grapher/StapParser.cxx | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index a9a5109a..2513680b 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -86,9 +86,12 @@ vector<string> commaSplit(const boost::sub_range<Glib::ustring>& range) using namespace boost; if (ioCondition & Glib::IO_HUP) { - childDiedSignal().emit(getPid()); - _ioConnection.disconnect(); - _errIoConnection.disconnect(); + if (_catchHUP) + { + childDiedSignal().emit(getPid()); + _ioConnection.disconnect(); + _errIoConnection.disconnect(); + } return true; } if ((ioCondition & Glib::IO_IN) == 0) @@ -261,22 +264,28 @@ vector<string> commaSplit(const boost::sub_range<Glib::ustring>& range) cerr << "StapParser: error reading from stderr!\n"; return true; } - if (write(STDOUT_FILENO, buf, bytes_read) < 0) + if (write(STDERR_FILENO, buf, bytes_read) < 0) ; return true; } - void StapParser::initIo(int inFd, int errFd) + void StapParser::initIo(int inFd, int errFd, bool catchHUP) { _inFd = inFd; _errFd = errFd; + _catchHUP = catchHUP; + Glib::IOCondition inCond = Glib::IO_IN; + if (catchHUP) + inCond |= Glib::IO_HUP; + if (_errFd >= 0) + { + _errIoConnection = Glib::signal_io() + .connect(sigc::mem_fun(*this, &StapParser::errIoCallback), + _errFd, Glib::IO_IN); + } _ioConnection = Glib::signal_io() - .connect(sigc::mem_fun(*this, &StapParser::errIoCallback), - _errFd, - Glib::IO_IN); - _errIoConnection = Glib::signal_io() .connect(sigc::mem_fun(*this, &StapParser::ioCallback), - _inFd, - Glib::IO_IN | Glib::IO_HUP); + _inFd, inCond); + } } |