From 09eaecb3c0b96dbd43305de61e7aa13a58adf187 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 1 Oct 2002 17:29:50 +0000 Subject: [PATCH] Use "kill" instead to monitor liveness of other process git-svn-id: https://svn.dealii.org/trunk@6583 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/source/sparse_direct.cc | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) 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 -- 2.39.5