From: Wolfgang Bangerth Date: Tue, 1 Oct 2002 17:29:50 +0000 (+0000) Subject: Use "kill" instead to monitor liveness of other process X-Git-Tag: v8.0.0~17402 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09eaecb3c0b96dbd43305de61e7aa13a58adf187;p=dealii.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/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