summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-01-22 11:56:38 -0500
committerNat Goodspeed <nat@lindenlab.com>2012-01-22 11:56:38 -0500
commit748d1b311fdecf123df40bd7d22dd7e19afaca84 (patch)
treef4d52790a8788ba4f6f3a7973acaa231893526ac
parentaa1bbe3277842a9a6e7db5227b35f1fbea50b7a6 (diff)
Add LLProcess logging on launch(), kill(), isRunning().
Much as I dislike viewer log spam, seems to me starting a child process, killing it and observing its termination are noteworthy events. New logging makes LLExternalEditor launch message redundant; removed.
-rw-r--r--indra/llcommon/llprocess.cpp34
-rw-r--r--indra/llcommon/llprocess.h7
-rw-r--r--indra/newview/llexternaleditor.cpp4
3 files changed, 30 insertions, 15 deletions
diff --git a/indra/llcommon/llprocess.cpp b/indra/llcommon/llprocess.cpp
index 9d6c19f1dd..6d329a3fa1 100644
--- a/indra/llcommon/llprocess.cpp
+++ b/indra/llcommon/llprocess.cpp
@@ -77,7 +77,7 @@ LLProcess::~LLProcess()
bool LLProcess::isRunning(void)
{
- mProcessID = isRunning(mProcessID);
+ mProcessID = isRunning(mProcessID, mDesc);
return (mProcessID != 0);
}
@@ -190,20 +190,23 @@ void LLProcess::launch(const LLSDParamAdapter<Params>& params)
throw LLProcessError(WindowsErrorString("CreateProcessA"));
}
+ // foo = pinfo.dwProcessId; // get your pid here if you want to use it later on
+ // CloseHandle(pinfo.hProcess); // stops leaks - nothing else
+ mProcessID = pinfo.hProcess;
+ CloseHandle(pinfo.hThread); // stops leaks - nothing else
+
+ mDesc = STRINGIZE('"' << std::string(params.executable) << "\" (" << pinfo.dwProcessId << ')');
+ LL_INFOS("LLProcess") << "Launched " << params << " (" << pinfo.dwProcessId << ")" << LL_ENDL;
+
// Now associate the new child process with our Job Object -- unless
// autokill is false, i.e. caller asserts the child should persist.
if (params.autokill)
{
- LLJob::instance().assignProcess(params.executable, pinfo.hProcess);
+ LLJob::instance().assignProcess(mDesc, mProcessID);
}
-
- // foo = pinfo.dwProcessId; // get your pid here if you want to use it later on
- // CloseHandle(pinfo.hProcess); // stops leaks - nothing else
- mProcessID = pinfo.hProcess;
- CloseHandle(pinfo.hThread); // stops leaks - nothing else
}
-LLProcess::id LLProcess::isRunning(id handle)
+LLProcess::id LLProcess::isRunning(id handle, const std::string& desc)
{
if (! handle)
return 0;
@@ -212,6 +215,10 @@ LLProcess::id LLProcess::isRunning(id handle)
if(waitresult == WAIT_OBJECT_0)
{
// the process has completed.
+ if (! desc.empty())
+ {
+ LL_INFOS("LLProcess") << desc << " terminated" << LL_ENDL;
+ }
return 0;
}
@@ -223,6 +230,7 @@ bool LLProcess::kill(void)
if (! mProcessID)
return false;
+ LL_INFOS("LLProcess") << "killing " << mDesc << LL_ENDL;
TerminateProcess(mProcessID, 0);
return ! isRunning();
}
@@ -369,9 +377,12 @@ void LLProcess::launch(const LLSDParamAdapter<Params>& params)
// parent process
mProcessID = child;
+
+ mDesc = STRINGIZE('"' << std::string(params.executable) << "\" (" << mProcessID << ')');
+ LL_INFOS("LLProcess") << "Launched " << params << " (" << mProcessID << ")" << LL_ENDL;
}
-LLProcess::id LLProcess::isRunning(id pid)
+LLProcess::id LLProcess::isRunning(id pid, const std::string& desc)
{
if (! pid)
return 0;
@@ -380,6 +391,10 @@ LLProcess::id LLProcess::isRunning(id pid)
if(reap_pid(pid))
{
// the process has exited.
+ if (! desc.empty())
+ {
+ LL_INFOS("LLProcess") << desc << " terminated" << LL_ENDL;
+ }
return 0;
}
@@ -393,6 +408,7 @@ bool LLProcess::kill(void)
// Try to kill the process. We'll do approximately the same thing whether
// the kill returns an error or not, so we ignore the result.
+ LL_INFOS("LLProcess") << "killing " << mDesc << LL_ENDL;
(void)::kill(mProcessID, SIGTERM);
// This will have the side-effect of reaping the zombie if the process has exited.
diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h
index 7dbdf23679..019c33592c 100644
--- a/indra/llcommon/llprocess.h
+++ b/indra/llcommon/llprocess.h
@@ -97,7 +97,7 @@ public:
typedef HANDLE id;
#else
typedef pid_t id;
-#endif
+#endif
/// Get platform-specific process ID
id getProcessID() const { return mProcessID; };
@@ -114,13 +114,14 @@ public:
* functionality should be added as nonstatic members operating on
* mProcessID.
*/
- static id isRunning(id);
-
+ static id isRunning(id, const std::string& desc="");
+
private:
/// constructor is private: use create() instead
LLProcess(const LLSDParamAdapter<Params>& params);
void launch(const LLSDParamAdapter<Params>& params);
+ std::string mDesc;
id mProcessID;
bool mAutokill;
};
diff --git a/indra/newview/llexternaleditor.cpp b/indra/newview/llexternaleditor.cpp
index 0d3ed0ba35..561b87618c 100644
--- a/indra/newview/llexternaleditor.cpp
+++ b/indra/newview/llexternaleditor.cpp
@@ -102,9 +102,7 @@ LLExternalEditor::EErrorCode LLExternalEditor::run(const std::string& file_path)
params.args.add(fixed);
}
- // Run the editor.
- llinfos << "Running editor command [" << params << "]" << llendl;
- // Prevent killing the process in destructor.
+ // Run the editor. Prevent killing the process in destructor.
params.autokill = false;
return LLProcess::create(params) ? EC_SUCCESS : EC_FAILED_TO_RUN;
}