32 #include <mach/mach_init.h>
33 #include <mach/shared_region.h>
34 #include <mach/task.h>
58 if (gethostname(host,
sizeof host) == -1)
59 warn(
"could not get host name!");
71 procInfo(
const char *filename,
const char *target)
78 FILE *
fp = fopen(filename,
"r");
80 while (
fp && !feof(
fp) && !done) {
81 if (fgets(line, 80,
fp)) {
103 struct task_basic_info t_info;
104 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
106 if (KERN_SUCCESS != task_info(mach_task_self(),
107 TASK_BASIC_INFO, (task_info_t)&t_info,
115 return (t_info.virtual_size - SHARED_REGION_SIZE) / 1024;
118 return procInfo(
"/proc/self/status",
"VmSize:");