diff --git a/checkin_notes b/checkin_notes index 497a70c3ab..a9f3a8fc99 100755 --- a/checkin_notes +++ b/checkin_notes @@ -10310,3 +10310,18 @@ Eric K 18 Sept 2006 client/ client_types.C + +Charlie 19 Sept 2006 + - Mac: Add process memory info for Mac, using a pipe to ps command. + Does not set the page_fault_count, user_time or kernel_time fields + in PROCINFO struct. See comments in procinfo_mac.C for other + values of possible interest that are avaiable from ps command. + - Fix compiler warning in http_curl.C. + + client/ + http_curl.C + lib/ + procinfo_mac.C (new) + mac_build/ + boinc.xcodeproj/ + project.pbxproj diff --git a/client/http_curl.C b/client/http_curl.C index 373d24e365..ccf33144e9 100644 --- a/client/http_curl.C +++ b/client/http_curl.C @@ -967,7 +967,7 @@ void HTTP_OP_SET::got_select(FDSET_GROUP&, double timeout) { if (hop->response >= 400) { strcpy(hop->error_msg, boincerror(hop->response)); } else { - sprintf(hop->error_msg, "HTTP error %d", hop->response); + sprintf(hop->error_msg, "HTTP error %ld", hop->response); } switch (hop->response) { case HTTP_STATUS_NOT_FOUND: diff --git a/lib/procinfo_mac.C b/lib/procinfo_mac.C new file mode 100644 index 0000000000..72bee0a507 --- /dev/null +++ b/lib/procinfo_mac.C @@ -0,0 +1,143 @@ +// Berkeley Open Infrastructure for Network Computing +// http://boinc.berkeley.edu +// Copyright (C) 2006 University of California +// +// This 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 2.1 of the License, or (at your option) any later version. +// +// This software 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. +// +// To view the GNU Lesser General Public License visit +// http://www.gnu.org/copyleft/lesser.html +// or write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +#include "config.h" +#include + +#include +#include +#include + +#include "procinfo.h" +#include "client_msgs.h" + +using std::vector; + + +// build table of all processes in system +// +int procinfo_setup(vector& pi) { + + FILE* fd; + PROCINFO p; + int c, real_mem, virtual_mem; + +// Some values of possible interest available from 'ps' command: +// %cpu percentage cpu usage (alias pcpu) +// %mem percentage memory usage (alias pmem) +// majflt total page faults +// minflt total page reclaims +// nswap total swaps in/out +// pid process ID +// ppid parent process ID +// poip pageouts in progress +// rss resident set size in Kbytes +// rsz resident set size + (text size / text use count) +// time accumulated cpu time, user + system +// vsz virtual size in Kbytes + + memset(&p, 0, sizeof(p)); + + fd = popen("ps -axopid,ppid,rss,vsz", "r"); + if (!fd) return 0; + + // Skip over the header line + do { + c = fgetc(fd); + if (c == EOF) { + pclose(fd); + return 0; + } + } while (c != '\n'); + + while (1) { + c = fscanf(fd, "%5d%6d%6d%9d\n", &p.id, &p.parentid, &real_mem, &virtual_mem); + if (c < 4) break; + p.working_set_size = (double)real_mem * 1024.; + p.swap_size = (double)virtual_mem * 1024.; + p.is_boinc_app = false; + pi.push_back(p); + + } + + pclose(fd); + return 0; +} + +// Scan the process table adding in CPU time and mem usage. Loop +// thru entire table as the entries aren't in order. Recurse at +// most 4 times to get additional child processes +// +void add_child_totals(PROCINFO& pi, vector& piv, int pid, int rlvl) { + unsigned int i; + + if (rlvl > 3) { + return; + } + for (i=0; i& piv) { + unsigned int i; + + for (i=0; i& piv) { + unsigned int i; + + memset(&pi, 0, sizeof(pi)); + for (i=0; i