}
}
-int get_pid_array(int arr[], const int n)
+static int get_pid_array(int arr[], const int n)
{
DIR *d = opendir("/proc");
struct dirent *dirent;
break;
}
}
- /* Calling code must guarantee this */
- assert(pid != -1);
return pid;
}
// return log length (>0) for normal case
// return negative value for error
-int get_system_info(struct system_info_t *sys_info, int* pidarray, int pidcount)
+int get_system_info(struct system_info_t *sys_info)
{
static int event_num = 0;
uint64_t sysmemtotal = 0;
float factor;
LOGI_th_samp("start\n");
- LOGI_th_samp("PID count : %d\n", pidcount);
memset(sys_info, 0, sizeof(*sys_info));
if (IS_OPT_SET(FL_CPU) ||
IS_OPT_SET(FL_PROCESSES) ||
IS_OPT_SET(FL_MEMORY)) {
+ const int max_pid_num = 1024; /* ugly hardcode */
+ int pidarray[max_pid_num];
+ int pidcount = 0;
+ pid_t first_target_pid = -1;
+
+ pidcount = get_pid_array(pidarray, max_pid_num);
+ LOGI_th_samp("PID count : %d\n", pidcount);
+
if (update_process_data(pidarray, pidcount, PROCDATA_STAT) < 0) {
LOGE("Failed to update process stat data\n");
goto fail_exit;
goto fail_exit;
}
- if (pidcount > 0)
- if (update_thread_data(get_first_target_process()) < 0) {
+ first_target_pid = get_first_target_process();
+ if (first_target_pid > 0)
+ if (update_thread_data(first_target_pid) < 0) {
LOGE("Failed to update thread stat data\n");
goto fail_exit;
}
uint32_t cpu_core_count;
};
-int get_pid_array(int pidarr[], const int n);
-int get_system_info(struct system_info_t *sys_info, int *pidarray, int pidcount);
+int get_system_info(struct system_info_t *sys_info);
int get_device_info(char* buffer, int buffer_len);
//static
void* samplingThread(void* data)
{
- int err, signo, i;
+ int err, signo;
sigset_t waitsigmask;
LOGI("sampling thread started\n");
}
if (signo == SIGALRM) {
- const int max_pid_num = 1024; /* ugly hardcode */
- int pidarr[max_pid_num];
- int pidcount = 0;
struct system_info_t sys_info;
struct msg_data_t *msg;
- pidcount = get_pid_array(pidarr, max_pid_num);
-
- if (get_system_info(&sys_info, pidarr, pidcount) == -1) {
+ if (get_system_info(&sys_info) == -1) {
LOGE("Cannot get system info\n");
//do not send sys_info because
//it is corrupted