From 473ed1c34b98b0515031eef9bfd3a140d8bb2c92 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Nov 2009 17:04:55 +0100 Subject: add experimental saving of /var/log/Xorg*.log for X crashes Signed-off-by: Denys Vlasenko --- lib/Plugins/RunApp.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'lib/Plugins/RunApp.cpp') diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index 3be7bdf4..a2aa6987 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -21,7 +21,6 @@ #include "RunApp.h" -#include #include "DebugDump.h" #include "ABRTException.h" #include "CommLayerInner.h" @@ -30,20 +29,39 @@ #define COMMAND 0 #define FILENAME 1 +using namespace std; + void CActionRunApp::Run(const char *pActionDir, const char *pArgs) { - update_client(_("Executing RunApp plugin...")); + /* Don't update_client() - actions run at crash time */ + log("RunApp('%s','%s')", pActionDir, pArgs); - std::string output; vector_string_t args; - parse_args(pArgs, args, '"'); - FILE *fp = popen(args[COMMAND].c_str(), "r"); + const char *cmd = args[COMMAND].c_str(); + if (!cmd[0]) + { + return; + } + +//FIXME: need to be able to escape " in .conf + /* Chdir to the dump dir. Command can analyze component and such. + * Example: + * test x"`cat component`" = x"xorg-x11-apps" && cp /var/log/Xorg.0.log . + */ +//Can do it using chdir() in child if we'd open-code popen + string cd_and_cmd = ssprintf("cd '%s'; %s", pActionDir, cmd); + FILE *fp = popen(cd_and_cmd.c_str(), "r"); if (fp == NULL) { - throw CABRTException(EXCEP_PLUGIN, "Can't execute " + args[COMMAND]); + /* Happens only on resource starvation (fork fails or out-of-mem) */ + return; } + +//FIXME: RunApp("gzip -9 1) + if (args.size() > FILENAME) { CDebugDump dd; dd.Open(pActionDir); -- cgit