From: wolf Date: Tue, 1 Oct 2002 17:29:50 +0000 (+0000) Subject: Use "kill" instead to monitor liveness of other process X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e40955f76b61513a23895663d683eaaf2d01d0da;p=dealii-svn.git Use "kill" instead to monitor liveness of other process git-svn-id: https://svn.dealii.org/trunk@6583 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/contrib/hsl/source/detached_ma27.cc b/deal.II/contrib/hsl/source/detached_ma27.cc index 9fa004877a..77e517f411 100644 --- a/deal.II/contrib/hsl/source/detached_ma27.cc +++ b/deal.II/contrib/hsl/source/detached_ma27.cc @@ -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 diff --git a/deal.II/lac/source/sparse_direct.cc b/deal.II/lac/source/sparse_direct.cc index 8c3f5ef2e9..551e1df71e 100644 --- a/deal.II/lac/source/sparse_direct.cc +++ b/deal.II/lac/source/sparse_direct.cc @@ -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