Browse Source

Merge pull request #923 from Tarik-B/TB-PLAY-BUTTON-LINUX

Fixed issue #588: stop button now changes back to play after stopping project (Linux)
JoshEngebretson 9 years ago
parent
commit
c3378db3fb
2 changed files with 18 additions and 5 deletions
  1. 2 0
      AUTHORS.md
  2. 16 5
      Source/Atomic/IPC/IPCUnix.cpp

+ 2 - 0
AUTHORS.md

@@ -33,6 +33,8 @@
 
 
 - JimMarlowe (https://github.com/JimMarlowe)
 - JimMarlowe (https://github.com/JimMarlowe)
 
 
+- Tarik Belabbas (https://github.com/Tarik-B)
+
 ### Contribution Copyright and Licensing
 ### Contribution Copyright and Licensing
 
 
 Atomic Game Engine contribution copyrights are held by their authors.  Each author retains the copyright to their contribution and agrees to irrevocably license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`.  Please see `CONTRIBUTING.md` for more details.
 Atomic Game Engine contribution copyrights are held by their authors.  Each author retains the copyright to their contribution and agrees to irrevocably license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`.  Please see `CONTRIBUTING.md` for more details.

+ 16 - 5
Source/Atomic/IPC/IPCUnix.cpp

@@ -24,9 +24,6 @@
 
 
 #include "IPCUnix.h"
 #include "IPCUnix.h"
 
 
-namespace Atomic
-{
-
 #include <unistd.h>
 #include <unistd.h>
 #include <signal.h>
 #include <signal.h>
 #include <sys/socket.h>
 #include <sys/socket.h>
@@ -36,6 +33,13 @@ namespace Atomic
 #include <libproc.h>
 #include <libproc.h>
 #endif
 #endif
 
 
+#ifdef ATOMIC_PLATFORM_LINUX
+#include <sys/wait.h>
+#endif
+
+namespace Atomic
+{
+
 #define HANDLE_EINTR(x) ({ \
 #define HANDLE_EINTR(x) ({ \
     typeof(x) __eintr_result__; \
     typeof(x) __eintr_result__; \
     do { \
     do { \
@@ -176,15 +180,22 @@ bool IPCProcess::IsRunning()
     if (pid_ == -1)
     if (pid_ == -1)
         return false;
         return false;
 
 
-#ifdef __APPLE__
+#if defined(ATOMIC_PLATFORM_OSX)
     char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
     char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
     int ret = proc_pidpath (pid_, pathbuf, sizeof(pathbuf));
     int ret = proc_pidpath (pid_, pathbuf, sizeof(pathbuf));
     if ( ret > 0 )
     if ( ret > 0 )
     {
     {
         return true;
         return true;
     }
     }
+#elif defined(ATOMIC_PLATFORM_LINUX)
+    int status;
+    pid_t childPid = waitpid( pid_, &status, WNOHANG );
+    bool childRunning = !WIFEXITED( status ) && !WIFSIGNALED( status ) && !WIFSTOPPED( status );
+    if ( childPid != pid_ || childRunning )
+    {
+        return true;
+    }
 #else
 #else
-
     // this doesn't seem to work on OSX?
     // this doesn't seem to work on OSX?
     if (kill(pid_, 0) == 0)
     if (kill(pid_, 0) == 0)
         return true;
         return true;