Log Message:
-----------
start/stop server on unix

Modified Files:
--------------
    pgadmin3/src/schema:
        pgServer.cpp (r1.50 -> r1.51)
    pgadmin3/src/include:
        misc.h (r1.43 -> r1.44)
    pgadmin3/src/utils:
        misc.cpp (r1.53 -> r1.54)

Index: pgServer.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgServer.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -Lsrc/schema/pgServer.cpp -Lsrc/schema/pgServer.cpp -u -w -r1.50 -r1.51
--- src/schema/pgServer.cpp
+++ src/schema/pgServer.cpp
@@ -149,6 +149,9 @@
         else
             GetServerRunning();     // ignore result, just to wait for startup
     }
+#else
+       wxString res = ExecProcess(serviceId + wxT(" start"));
+       done = (res.Find(wxT("tarting")) > 0);
 #endif
     return done;
 }
@@ -170,10 +173,14 @@
                 serviceId.c_str(), rc);
         }
     }
+#else
+       wxString res = ExecProcess(serviceId + wxT(" stop"));
+       done = (res.Find(wxT("stopped")) > 0);
 #endif
     return done;
 }
 
+
 bool pgServer::GetServerRunning()
 {
     bool done=false;
@@ -202,6 +209,11 @@
                 break;
         }
     }
+#else
+
+       wxString res = ExecProcess(serviceId + wxT(" status"));
+       done = (res.Find(wxT("PID: ")) > 0);
+
 #endif
     return done;
 }
@@ -227,7 +239,7 @@
 #ifdef WIN32
     return serviceHandle != 0;
 #else
-    return false;
+    return !serviceId.IsEmpty();
 #endif
 }
 
Index: misc.h
===================================================================
RCS file: /projects/pgadmin3/src/include/misc.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -Lsrc/include/misc.h -Lsrc/include/misc.h -u -w -r1.43 -r1.44
--- src/include/misc.h
+++ src/include/misc.h
@@ -133,6 +133,9 @@
 void DisplayHelp(wxWindow *wnd, const wxString &helpTopic, char **icon=0);
 void DisplaySqlHelp(wxWindow *wnd, const wxString &helpTopic, char **icon=0);
 
+#ifndef WIN32
+wxString ExecProcess(const wxString &cmd);
+#endif
 
 
 enum        // depends on frmMain browserImages->Add order!
Index: misc.cpp
===================================================================
RCS file: /projects/pgadmin3/src/utils/misc.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -Lsrc/utils/misc.cpp -Lsrc/utils/misc.cpp -u -w -r1.53 -r1.54
--- src/utils/misc.cpp
+++ src/utils/misc.cpp
@@ -530,3 +530,23 @@
         DisplayHelp(wnd, wxT("pg/") + helpTopic, icon);
 }
 
+
+#ifndef WIN32
+wxString ExecProcess(const wxString &cmd)
+{
+    wxString res;
+       FILE *f=popen(cmd.ToAscii(), "r");
+
+       if (f)
+       {
+               char buffer[1024];
+               int cnt;
+               while ((cnt = fread(buffer, 1, 1024, f)) > 0)
+               {
+                       res += wxString::FromAscii(buffer);
+               }
+               pclose(f);
+       }
+       return res;
+}
+#endif
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to