// build/run probes // Copyright (C) 2005 Red Hat Inc. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General // Public License (GPL); either version 2, or (at your option) any // later version. #include "config.h" #include "buildrun.h" #include #include extern "C" { #include "signal.h" } using namespace std; // return as quoted string, with at least '"' backslash-escaped template inline string lex_cast_qstring(IN const & in) { stringstream ss; string out, out2; if (!(ss << in)) throw runtime_error("bad lexical cast"); out = ss.str(); out2 += '"'; for (unsigned i=0; i static string stringify(T t) { ostringstream s; s << t; return s.str (); } int run_pass (systemtap_session& s) { int rc = 0; if (s.test_mode) { string run_cmd = s.tmpdir + "/" + s.module_name; if (s.verbose) clog << "Running " << run_cmd << endl; rc = system (run_cmd.c_str ()); } else // real run { // leave parent process alone sighandler_t oldsig = signal (SIGINT, SIG_IGN); // for now, just spawn stpd string stpd_cmd = string("sudo ") + string(PKGLIBDIR) + "/stpd " + (s.bulk_mode ? "" : "-r ") + (s.verbose ? "" : "-q ") + (s.output_file.empty() ? "" : "-o " + s.output_file + " "); if (s.cmd != "") stpd_cmd += "-c \"" + s.cmd + "\" "; if (s.target_pid) stpd_cmd += "-t " + stringify(s.target_pid) + " "; if (s.buffer_size) stpd_cmd += "-b " + stringify(s.buffer_size) + " "; stpd_cmd += s.tmpdir + "/" + s.module_name + ".ko"; if (s.verbose) clog << "Running " << stpd_cmd << endl; rc = system (stpd_cmd.c_str ()); signal (SIGINT, oldsig); } return rc; }