Browse Source

Merge pull request #699 from AtomicGameEngine/JME-ATOMIC-IPCOTHERPROCESS

Adding accessor for IPC other process, terminate for Windows
JoshEngebretson 9 years ago
parent
commit
62637c4be8

+ 2 - 0
Source/Atomic/IPC/IPCChannel.h

@@ -58,6 +58,8 @@ public:
 
     void PostMessage(StringHash eventType, VariantMap& eventData);
 
+    IPCProcess* GetOtherProcess() { return otherProcess_; }
+
 protected:
 
     unsigned id_;

+ 3 - 1
Source/Atomic/IPC/IPCUnix.h

@@ -78,12 +78,14 @@ class IPCProcess : public Object
 
     public:
 
-        IPCProcess(Context* context, int fd1, int fd2, int pid = -1);
+    IPCProcess(Context* context, int fd1, int fd2, int pid = -1);
 
     virtual ~IPCProcess();
 
     bool IsRunning();
 
+    bool Terminate() { return true; }
+
     int fd1() const { return fd1_; }
     int fd2() const { return fd2_; }
 

+ 11 - 0
Source/Atomic/IPC/IPCWindows.cpp

@@ -263,6 +263,17 @@ IPCProcess::~IPCProcess()
 
 }
 
+bool IPCProcess::Terminate()
+{
+    if (TerminateProcess(pid_, 0))
+    {
+        WaitForSingleObject(pid_, 1000);
+        return true;
+    }
+        
+    return false;
+}
+
 bool IPCProcess::IsRunning()
 {
     DWORD exitCode;

+ 3 - 1
Source/Atomic/IPC/IPCWindows.h

@@ -115,12 +115,14 @@ class IPCProcess : public Object
 
     public:
 
-        IPCProcess(Context* context, IPCHandle clientRead, IPCHandle clientWrite, IPCHandle pid = INVALID_IPCHANDLE_VALUE);
+    IPCProcess(Context* context, IPCHandle clientRead, IPCHandle clientWrite, IPCHandle pid = INVALID_IPCHANDLE_VALUE);
 
     virtual ~IPCProcess();
 
     bool IsRunning();
 
+    bool Terminate();
+
     IPCHandle clientRead() const { return clientRead_; }
     IPCHandle clientWrite() const { return clientWrite_; }