]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use "kill" instead to monitor liveness of other process
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 1 Oct 2002 17:29:50 +0000 (17:29 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 1 Oct 2002 17:29:50 +0000 (17:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@6583 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/contrib/hsl/source/detached_ma27.cc
deal.II/lac/source/sparse_direct.cc

index 9fa004877afa13ac9a323dd76cf23da78ce55261..77e517f4110517b4d47307a21c0b2d8d856ac7f5 100644 (file)
@@ -134,24 +134,25 @@ void die (const std::string &text, const T1 t1, const T2 t2)
 extern "C"
 void monitor_parent_liveness (const pid_t master_pid) 
 {
-#ifdef HAVE_STD_STRINGSTREAM
-  std::ostringstream s;
-  s << "ps -p " << master_pid;
-  const char * const command = s.str().c_str();
-#else
-  std::ostrstream s;
-  s << "ps -p " << master_pid << std::ends;
-  const char * const command = s.str();
-#endif
+// #ifdef HAVE_STD_STRINGSTREAM
+//   std::ostringstream s;
+//   s << "ps -p " << master_pid;
+//   const char * const command = s.str().c_str();
+// #else
+//   std::ostrstream s;
+//   s << "ps -p " << master_pid << std::ends;
+//   const char * const command = s.str();
+// #endif
   
   while (true)
     {
-      int ret = std::system (command);
-      if (ret < 0)
-        die ("Monitor process couldn't start 'ps'!");
-      else
-        if (ret != 0)
+//      int ret = std::system (command);
+      int ret = kill (master_pid, 0);
+      if (ret != 0)
+        if (ret == ESRCH)
           die ("Master process seems to have died!");
+        else
+          die ("Unspecified error while checking for other process!");
 
                                        // ok, master still running,
                                        // take a little rest and then
index 8c3f5ef2e9c07bfa0ab185778d258a5a371cbe32..551e1df71eb64376f2e26af3dd3f90358cc42502 100644 (file)
@@ -311,24 +311,30 @@ void die (const std::string &text, const T1 t1, const T2 t2)
 extern "C"
 void monitor_child_liveness (const pid_t child_pid) 
 {
-#ifdef HAVE_STD_STRINGSTREAM
-  std::ostringstream s;
-  s << "ps -p " << child_pid;
-  const char * const command = s.str().c_str();
-#else
-  std::ostrstream s;
-  s << "ps -p " << child_pid << std::ends;
-  const char * const command = s.str();
-#endif
+// #ifdef HAVE_STD_STRINGSTREAM
+//   std::ostringstream s;
+//   s << "ps -p " << child_pid;
+//   const char * const command = s.str().c_str();
+// #else
+//   std::ostrstream s;
+//   s << "ps -p " << child_pid << std::ends;
+//   const char * const command = s.str();
+// #endif
   
   while (true)
     {
-      int ret = std::system (command);
-      if (ret < 0)
-        die ("Monitor process couldn't start 'ps'!");
-      else
-        if (ret != 0)
+//       int ret = std::system (command);
+//       if (ret < 0)
+//         die ("Monitor process couldn't start 'ps'!");
+//       else
+//         if (ret != 0)
+//           die ("Child process seems to have died!");
+      int ret = kill (child_pid, 0);
+      if (ret != 0)
+        if (ret == ESRCH)
           die ("Child process seems to have died!");
+        else
+          die ("Unspecified error while checking for other process!");
 
                                        // ok, master still running,
                                        // take a little rest and then

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.