Browse Source

Fixed issue #588: stop button now changes back to play after stopping project (Linux).

Snake 9 years ago
parent
commit
f22da3610a
1 changed files with 16 additions and 5 deletions
  1. 16 5
      Source/Atomic/IPC/IPCUnix.cpp

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

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