From 1d1bc5d0e8facf6133dd57db3a1e386c700935c6 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 23 Feb 2011 00:28:52 +0000 Subject: [PATCH] svn path=/trunk/boinc/; revision=23087 --- lib/procinfo.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 lib/procinfo.cpp diff --git a/lib/procinfo.cpp b/lib/procinfo.cpp new file mode 100644 index 0000000000..9651b60fc3 --- /dev/null +++ b/lib/procinfo.cpp @@ -0,0 +1,87 @@ +// This file is part of BOINC. +// http://boinc.berkeley.edu +// Copyright (C) 2011 University of California +// +// BOINC is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// BOINC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + +// platform-independent process-enumeration functions + +#ifndef _WIN32 +#include +#include +#include +#endif + +#include "procinfo.h" + +using std::vector; + +static void get_descendants_aux(vector& piv, int pid, vector& pids) { + for (unsigned int i=0; i& pids) { + int retval; + vector piv; + retval = procinfo_setup(piv); + if (retval) return; + get_descendants_aux(piv, pid, pids); +} + + +#ifndef _WIN32 + +// get resource usage of non-BOINC apps +// +void procinfo_other(PROCINFO& pi, vector& piv) { + unsigned int i; + + memset(&pi, 0, sizeof(pi)); + for (i=0; i& pids) { + int status; + for (unsigned int i=0; i= 0) { + return true; + } + } + return false; +} + +void kill_all(vector& pids) { + for (unsigned int i=0; i