summaryrefslogtreecommitdiff
path: root/indra/llcommon/llprocesslauncher.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-01-18 01:09:50 -0500
committerNat Goodspeed <nat@lindenlab.com>2012-01-18 01:09:50 -0500
commit06f9dbd8db9895f81d7bd325d8cf616f68533396 (patch)
treecaff25fd1311de2e9140c9da096eed4e8043b932 /indra/llcommon/llprocesslauncher.cpp
parent4bfd84d3be8d33bc6eb0dab22d2b3034de0800c9 (diff)
Introduce static LLProcessLauncher::isRunning(ll_pid_t) method.
typedef LLProcessLauncher::ll_pid_t to be HANDLE on Windows, pid_t elsewhere. Then we can define getProcessID() returning ll_pid_t on all platforms, retaining getProcessHandle() for hypothetical existing consumers... of which there are none in practice. This lets us define isRunning(ll_pid_t) to encapsulate the platform-specific logic to actually check on a running child process, turning non-static isRunning() into a fairly trivial wrapper.
Diffstat (limited to 'indra/llcommon/llprocesslauncher.cpp')
-rw-r--r--indra/llcommon/llprocesslauncher.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/indra/llcommon/llprocesslauncher.cpp b/indra/llcommon/llprocesslauncher.cpp
index 25d64e9e28..e1af49c2fb 100644
--- a/indra/llcommon/llprocesslauncher.cpp
+++ b/indra/llcommon/llprocesslauncher.cpp
@@ -143,18 +143,25 @@ int LLProcessLauncher::launch(void)
bool LLProcessLauncher::isRunning(void)
{
- if(mProcessHandle != 0)
+ mProcessHandle = isRunning(mProcessHandle);
+ return (mProcessHandle != 0);
+}
+
+LLProcessLauncher::ll_pid_t LLProcessLauncher::isRunning(ll_pid_t handle)
+{
+ if (! handle)
+ return 0;
+
+ DWORD waitresult = WaitForSingleObject(handle, 0);
+ if(waitresult == WAIT_OBJECT_0)
{
- DWORD waitresult = WaitForSingleObject(mProcessHandle, 0);
- if(waitresult == WAIT_OBJECT_0)
- {
- // the process has completed.
- mProcessHandle = 0;
- }
+ // the process has completed.
+ return 0;
}
- return (mProcessHandle != 0);
+ return handle;
}
+
bool LLProcessLauncher::kill(void)
{
bool result = true;
@@ -293,19 +300,25 @@ int LLProcessLauncher::launch(void)
bool LLProcessLauncher::isRunning(void)
{
- if(mProcessID != 0)
- {
- // Check whether the process has exited, and reap it if it has.
- if(reap_pid(mProcessID))
- {
- // the process has exited.
- mProcessID = 0;
- }
- }
-
+ mProcessID = isRunning(mProcessID);
return (mProcessID != 0);
}
+LLProcessLauncher::ll_pid_t LLProcessLauncher::isRunning(ll_pid_t pid)
+{
+ if (! pid)
+ return 0;
+
+ // Check whether the process has exited, and reap it if it has.
+ if(reap_pid(pid))
+ {
+ // the process has exited.
+ return 0;
+ }
+
+ return pid;
+}
+
bool LLProcessLauncher::kill(void)
{
bool result = true;